JSFiddle - React, Tailwind, and code Playground
by skirtle
HTML
<script src="https://unpkg.com/[email protected]/dist/vue.global.js"></script>
JavaScript
const obj = Vue.reactive({
a: 1,
b: 2
})
Vue.watch([() => obj.a, () => obj.b], v => {
console.log('first', v)
})
Vue.watch(() => [obj.a, obj.b], v => {
console.log('second', v)
})
// This changes the value but then sets it back again.
// As a result, the first watch doesn't log
obj.a = 9
obj.a = 1
Vue.nextTick(() => {
console.log('----')
// This time, both will log
obj.a = 7
})