当前位置:网站首页>Torefs API and toref API
Torefs API and toref API
2022-07-07 07:10:00 【To be a woman of light】
1. If we use ES6 Deconstruction grammar of , Yes reactive The returned object is deconstructed to obtain the value , Then, whether it is to modify the value after deconstruction , Or modify reactive Back to state object , Data is no longer responsive :
const info=reactive({
name:"jiang",
age:18
});
let {name,age}=info2. Is there a way for us to deconstruct properties that are responsive ?
- Vue It provides us with a toRefs Function of , Can be reactive The properties in the returned object are converted to ref;
- Then we deconstruct it again name and age In itself ref Of ;
// When we do this , Will return two ref object , They are responsive
let {name,age}=toRefs(info)
//1.toRefs: take reactive All properties in the object are converted to ref, Building links 3. This approach is equivalent to info.name and refvalue A link has been established between , Any modification will cause another change ;
toRefs and toRef The difference between
- toRefs: take reactive All properties in the object are converted to ref, Building links
- toRef: Convert one of the attributes into ref, Establishing a connection
let {name}=info
let age=toRef(info,"age");边栏推荐
- Pass parent component to child component: props
- Network foundation - header, encapsulation and unpacking
- 非父子组件的通信
- SolidWorks GB Library (steel profile library, including aluminum profile, aluminum tube and other structures) installation and use tutorial (generating aluminum profile as an example)
- Comment les entreprises gèrent - elles les données? Partager les leçons tirées des quatre aspects de la gouvernance des données
- CompletableFuture使用详解
- Databinding exception of kotlin
- linux系统rpm方式安装的mysql启动失败
- Libcurl returns curlcode description
- Leetcode t1165: log analysis
猜你喜欢

Answer to the first stage of the assignment of "information security management and evaluation" of the higher vocational group of the 2018 Jiangsu Vocational College skills competition

Matlab tips (29) polynomial fitting plotfit

2018年江苏省职业院校技能大赛高职组“信息安全管理与评估”赛项任务书

How does an enterprise manage data? Share the experience summary of four aspects of data governance

ANR 原理及实践

Basic introduction of JWT

DHCP路由器工作原理

Brand · consultation standardization

Composition API 前提

Jetpack compose is much more than a UI framework~
随机推荐
Multidisciplinary integration
Distributed ID solution
$parent(获取父组件) 和 $root(获取根组件)
Please tell me how to monitor multiple schemas and tables by listening to PgSQL
MOS管参数μCox得到的一种方法
The latest trends of data asset management and data security at home and abroad
JWT的基础介绍
CompletableFuture使用详解
Nesting and splitting of components
Tujia, muniao, meituan... Home stay summer war will start
Sqlserver multithreaded query problem
【mysqld】Can't create/write to file
ANR 原理及实践
Libcurl returns curlcode description
7天零基础能考证HCIA吗?华为认证系统学习路线分享
Use of completable future
Release notes of JMeter version 5.5
How Oracle backs up indexes
Explain Bleu in machine translation task in detail
$refs:组件中获取元素对象或者子组件实例: