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

类型声明

ts
export declare function 
watchImmediate
<
T
extends
Readonly
<
WatchSource
<unknown>[]>,
>(
source
: [...
T
],
cb
:
WatchCallback
<
MapSources
<
T
>,
MapOldSources
<
T
, true>>,
options
?:
Omit
<
WatchOptions
<true>, "immediate">,
):
WatchStopHandle
export declare function
watchImmediate
<
T
>(
source
:
WatchSource
<
T
>,
cb
:
WatchCallback
<
T
,
T
| undefined>,
options
?:
Omit
<
WatchOptions
<true>, "immediate">,
):
WatchStopHandle
export declare function
watchImmediate
<
T
extends object>(
source
:
T
,
cb
:
WatchCallback
<
T
,
T
| undefined>,
options
?:
Omit
<
WatchOptions
<true>, "immediate">,
):
WatchStopHandle

源代码

源代码文档

变更日志

最近没有更改