Skip to content

Commit

Permalink
总结shallowReactive和shallowRef
Browse files Browse the repository at this point in the history
  • Loading branch information
Panyue-genkiyo committed Oct 13, 2021
1 parent e770d7e commit dd76b1f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,3 +373,15 @@ npm run dev


- 扩展:```toRefs``````toRef```功能一致,但可以批量创建多个 ref 对象,语法:```toRefs(person)```


# 三、其它 Composition API

## 1.shallowReactive 与 shallowRef

- shallowReactive:只处理对象最外层属性的响应式(浅响应式)。
- shallowRef:只处理基本数据类型的响应式, 不进行对象的响应式处理。

- 什么时候使用?
- 如果有一个对象数据,结构比较深, 但变化时只是外层属性变化 ===> shallowReactive。
- 如果有一个对象数据,后续功能不会修改该对象中的属性,而是生新的对象来替换 ===> shallowRef。

0 comments on commit dd76b1f

Please sign in to comment.