Skip to content

Commit

Permalink
总结toRef和toRefs
Browse files Browse the repository at this point in the history
  • Loading branch information
Panyue-genkiyo committed Oct 13, 2021
1 parent 60b452b commit 91eab35
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,13 @@ npm run dev
- 类似于vue2.x中的mixin。

- 自定义hook的优势: 复用代码, 让setup中的逻辑更清楚易懂。


## 10.toRef

- 作用:创建一个 ref 对象,其value值指向另一个对象中的某个属性。
- 语法:```const name = toRef(person,'name')```
- 应用: 要将响应式对象中的某个属性单独提供给外部使用时。


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

0 comments on commit 91eab35

Please sign in to comment.