From d4e20bc2484928b13b8cc2b8f7ea98326fd0cd3b Mon Sep 17 00:00:00 2001 From: xufanglu <3146974+likev@users.noreply.github.com> Date: Fri, 19 Mar 2021 00:40:16 +0800 Subject: [PATCH 1/2] Update instance-methods.md --- src/api/instance-methods.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api/instance-methods.md b/src/api/instance-methods.md index 64cdaffac7..da5c0bb82e 100644 --- a/src/api/instance-methods.md +++ b/src/api/instance-methods.md @@ -121,7 +121,9 @@ - **Option: deep** - To also detect nested value changes inside Objects, you need to pass in `deep: true` in the options argument. Note that you don't need to do so to listen for array mutations. + To also detect nested value changes inside Objects, you need to pass in `deep: true` in the options argument. Note that in Vue3 you **also** need to do so to listen for array mutations. + + > Note: when mutating (rather than replacing) an Object or an Array and watch with deep option, the old value will be the same as new value because they reference the same Object/Array. Vue doesn't keep a copy of the pre-mutate value. ```js vm.$watch('someObject', callback, { From 34f70a14bd3d889d7551afbfcbf6a91c74ce4c46 Mon Sep 17 00:00:00 2001 From: xufanglu <3146974+likev@users.noreply.github.com> Date: Sat, 20 Mar 2021 17:11:46 +0800 Subject: [PATCH 2/2] Update src/api/instance-methods.md Co-authored-by: Natalia Tepluhina --- src/api/instance-methods.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/instance-methods.md b/src/api/instance-methods.md index da5c0bb82e..ef09dce96f 100644 --- a/src/api/instance-methods.md +++ b/src/api/instance-methods.md @@ -121,7 +121,7 @@ - **Option: deep** - To also detect nested value changes inside Objects, you need to pass in `deep: true` in the options argument. Note that in Vue3 you **also** need to do so to listen for array mutations. + To also detect nested value changes inside Objects, you need to pass in `deep: true` in the options argument. This option also can be used to watch array mutations. > Note: when mutating (rather than replacing) an Object or an Array and watch with deep option, the old value will be the same as new value because they reference the same Object/Array. Vue doesn't keep a copy of the pre-mutate value.