Skip to content

watchDeep

类别
导出体积
113 B
上次更改
6 minutes ago

使用 { deep: true } 监听值的简写形式。

使用方法

类似于 watch,但使用 { deep: true }

ts
import { 
watchDeep
} from '@vueuse/core'
const
nestedObject
=
ref
({
foo
: {
bar
: {
deep
: 5 } } })
watchDeep
(
nestedObject
, (
updated
) => {
console
.
log
(
updated
)
})
onMounted
(() => {
nestedObject
.
value
.
foo
.
bar
.
deep
= 10
})

类型声明

ts
export declare function 
watchDeep
<
T
extends
Readonly
<
WatchSource
<unknown>[]>,
Immediate
extends
Readonly
<boolean> = false,
>(
source
: [...
T
],
cb
:
WatchCallback
<
MapSources
<
T
>,
MapOldSources
<
T
,
Immediate
>>,
options
?:
Omit
<
WatchOptions
<
Immediate
>, "deep">,
):
WatchHandle
export declare function
watchDeep
<
T
,
Immediate
extends
Readonly
<boolean> = false,
>(
source
:
WatchSource
<
T
>,
cb
:
WatchCallback
<
T
,
Immediate
extends true ?
T
| undefined :
T
>,
options
?:
Omit
<
WatchOptions
<
Immediate
>, "deep">,
):
WatchHandle
export declare function
watchDeep
<
T
extends object,
Immediate
extends
Readonly
<boolean> = false,
>(
source
:
T
,
cb
:
WatchCallback
<
T
,
Immediate
extends true ?
T
| undefined :
T
>,
options
?:
Omit
<
WatchOptions
<
Immediate
>, "deep">,
):
WatchHandle

源码

源码文档

贡献者

一纸忘忧
Anthony Fu
Arthur Darkstone
Anthony Fu
山吹色御守
jp-liu
Kyrie890514
Alex Liu
丶远方
Hammad Asif

更新日志

b8102 - feat(watch): update watch return typo in watchExtractedObservable, watchDebounced, watchDeep, watchImmediate, watchOnce, watchThrottled and watchWithFilter (#4896)
00a72 - fix(types): update type casting for watch functions to use WatchSource (#4966)
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)
0716d - fix: unify overload declaration for watch functions (#4043)