Skip to content

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
})