A Vue implantation of the double requestAnimationFrame method to force nextTick()
npm install vue-force-next-tick> When you need to ensure the DOM has been updated Vue's nextTick just doesn't work. You will need to use the double requestAnimationFrame method. This is an elegant wrapper to allow you to use the double requestAnimationFrame method within your Vue applications either globally Vue.$forceNextTick(callback) or within a method this.$forceNextTick(callback)
``bash
npm i vue-force-next-tick
yarn add vue-force-next-tick
`
javascript
import Vue from 'vue'
import VueForceNextTick from 'vue-force-next-tick'
Vue.use(VueForceNextTick)
`A bit of History
How does double requestanimationframe work
VueJS: How to wait for a browser re-render? Vue.nextTick doesn't seem to cover it.
Inspired by the advice of [Justineo] (https://github.com/Justineo)
Usage
$3
`javascript
Vue.$forceNextTick(() => {
// Your code here.
})// or
await Vue.$forceNextTick()
`$3
`javascript
methods: {
yourMethod () {
this.$forceNextTick(() => {
// Your code here.
})
}
// or
async yourMethod () {
await this.$forceNextTick()
// Your code here.
}
}
`$3
`javascript
@click="doSomethingBig"
>
Lets count to 10 million!
``