当前位置:网站首页>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}=info
2. 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");
边栏推荐
- MySql用户权限
- Learning records on July 4, 2022
- Pass parent component to child component: props
- 【mysqld】Can't create/write to file
- MySQL binlog related commands
- Academic report series (VI) - autonomous driving on the journey to full autonomy
- MYSQL----导入导出&视图&索引&执行计划
- 什么情况下考虑分库分表
- Select the product attribute pop-up box to pop up the animation effect from the bottom
- Networkx drawing and common library function coordinate drawing
猜你喜欢
Master-slave replication principle of MySQL
SolidWorks GB Library (steel profile library, including aluminum profile, aluminum tube and other structures) installation and use tutorial (generating aluminum profile as an example)
MOS tube parameters μ A method of Cox
组件的嵌套和拆分
Graduation design game mall
【NOI模拟赛】区域划分(结论,构造)
7天零基础能考证HCIA吗?华为认证系统学习路线分享
MySQL SQL的完整处理流程
Esxi attaching mobile (Mechanical) hard disk detailed tutorial
Composition API 前提
随机推荐
Get the city according to IP
关于数据库数据转移的问题,求各位解答下
Circulating tumor cells - here comes abnova's solution
什么情况下考虑分库分表
2018年江苏省职业院校技能大赛高职组“信息安全管理与评估”赛项任务书
sql中对集合进行非空校验
$parent(获取父组件) 和 $root(获取根组件)
Graduation design game mall
Distributed ID solution
Pass child component to parent component
js小练习
Communication between non parent and child components
组件的通信
FullGC问题分析及解决办法总结
Asynchronous components and suspend (in real development)
Databinding exception of kotlin
MySql用户权限
Bus message bus
sqlserver多线程查询问题
Libcurl returns curlcode description