主题
watchImmediate
用于监视 {immediate: true} 值的快捷方式
🌐 Shorthand for watching value with {immediate: true}
用法
🌐 Usage
类似于 watch,但是有 { immediate: true }
🌐 Similar to watch, but with { immediate: true }
ts
import { watchImmediate } from '@vueuse/core'
const obj = ref('vue-use')
// changing the value from some external store/composables
obj.value = 'VueUse'
watchImmediate(obj, (updated) => {
console.log(updated) // Console.log will be logged twice
})