From dd76b1f740ba6d85eda3d792ac2d57d4665d095b Mon Sep 17 00:00:00 2001 From: panyue <90938238g@gmail.com> Date: Wed, 13 Oct 2021 22:41:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=BB=E7=BB=93shallowReactive=E5=92=8Cshall?= =?UTF-8?q?owRef?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 9e121d0..c0e2a39 100644 --- a/README.md +++ b/README.md @@ -373,3 +373,15 @@ npm run dev - 扩展:```toRefs``` 与```toRef```功能一致,但可以批量创建多个 ref 对象,语法:```toRefs(person)``` + + +# 三、其它 Composition API + +## 1.shallowReactive 与 shallowRef + +- shallowReactive:只处理对象最外层属性的响应式(浅响应式)。 +- shallowRef:只处理基本数据类型的响应式, 不进行对象的响应式处理。 + +- 什么时候使用? + - 如果有一个对象数据,结构比较深, 但变化时只是外层属性变化 ===> shallowReactive。 + - 如果有一个对象数据,后续功能不会修改该对象中的属性,而是生新的对象来替换 ===> shallowRef。