From 91eab3585af09b13f37db718a3458a68caa1f36a Mon Sep 17 00:00:00 2001 From: panyue <90938238g@gmail.com> Date: Wed, 13 Oct 2021 22:17:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=BB=E7=BB=93toRef=E5=92=8CtoRefs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index aa6b677..9e121d0 100644 --- a/README.md +++ b/README.md @@ -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)```