当前位置:网站首页>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");
边栏推荐
- Four goals for the construction of intelligent safety risk management and control platform for hazardous chemical enterprises in Chemical Industry Park
- Config分布式配置中心
- MATLAB小技巧(29)多项式拟合 plotfit
- 2018年江苏省职业院校技能大赛高职组“信息安全管理与评估”赛项任务书第二阶段答案
- Graduation design game mall
- 数据资产管理与数据安全国内外最新趋势
- main函数在import语句中的特殊行为
- 什么情况下考虑分库分表
- 多个kubernetes集群如何实现共享同一个存储
- 栈题目:有效括号的嵌套深度
猜你喜欢
2022年全国所有A级景区数据(13604条)
Take you to brush (niuke.com) C language hundred questions (the first day)
Release notes of JMeter version 5.5
.net 5 FluentFTP连接FTP失败问题:This operation is only allowed using a successfully authenticated context
Circulating tumor cells - here comes abnova's solution
How can brand e-commerce grow against the trend? See the future here!
基于JS的迷宫小游戏
Esxi attaching mobile (Mechanical) hard disk detailed tutorial
Lvs+kept (DR mode) learning notes
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
随机推荐
Sword finger offer high quality code
Algorithm --- bit count (kotlin)
带你刷(牛客网)C语言百题(第一天)
MYSQL----导入导出&视图&索引&执行计划
2018年江苏省职业院校技能大赛高职组“信息安全管理与评估”赛项任务书
JDBC database connection pool usage problem
From zero to one, I will teach you to build the "clip search by text" search service (2): 5 minutes to realize the prototype
toRefs API 与 toRef Api
freeswitch拨打分机号源代码跟踪
sql中对集合进行非空校验
Config distributed configuration center
Lvs+kept (DR mode) learning notes
How DHCP router works
基于JS的迷宫小游戏
Use of completable future
[noi simulation] regional division (conclusion, structure)
Basic introduction of JWT
多个kubernetes集群如何实现共享同一个存储
Complete process of MySQL SQL
sqlserver多线程查询问题