当前位置:网站首页>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");
边栏推荐
- 工具类:对象转map 驼峰转下划线 下划线转驼峰
- Academic report series (VI) - autonomous driving on the journey to full autonomy
- 选择商品属性弹框从底部弹出动画效果
- 多个kubernetes集群如何实现共享同一个存储
- 2018年江苏省职业院校技能大赛高职组“信息安全管理与评估”赛项任务书第二阶段答案
- MATLAB小技巧(29)多项式拟合 plotfit
- .net 5 FluentFTP连接FTP失败问题:This operation is only allowed using a successfully authenticated context
- [explanation of JDBC and internal classes]
- 多线程与高并发(9)——AQS其他同步组件(Semaphore、ReentrantReadWriteLock、Exchanger)
- [noi simulation] regional division (conclusion, structure)
猜你喜欢
Prime partner of Huawei machine test questions
How to model and simulate the target robot [mathematical / control significance]
How can clothing stores make profits?
Four goals for the construction of intelligent safety risk management and control platform for hazardous chemical enterprises in Chemical Industry Park
子组件传递给父组件
基于JS的迷宫小游戏
How DHCP router works
Config分布式配置中心
SolidWorks GB Library (steel profile library, including aluminum profile, aluminum tube and other structures) installation and use tutorial (generating aluminum profile as an example)
Anr principle and Practice
随机推荐
ViewModelProvider. Of obsolete solution
LC interview question 02.07 Linked list intersection & lc142 Circular linked list II
Special behavior of main function in import statement
linux系统rpm方式安装的mysql启动失败
$parent(获取父组件) 和 $root(获取根组件)
JWT的基础介绍
MOS tube parameters μ A method of Cox
Brand · consultation standardization
from . onnxruntime_ pybind11_ State Import * noqa ddddocr operation error
Distributed ID solution
2018年江苏省职业院校技能大赛高职组“信息安全管理与评估”赛项任务书
MySQL的主从复制原理
2022年全国所有A级景区数据(13604条)
Non empty verification of collection in SQL
RuntimeError: CUDA error: CUBLAS_ STATUS_ ALLOC_ Failed when calling `cublascreate (handle) `problem solving
.net core 访问不常见的静态文件类型(MIME 类型)
Matlab tips (30) nonlinear fitting lsqcurefit
js小练习
Please ask a question, flick Oracle CDC, read a table without update operation, and repeatedly read the full amount of data every ten seconds
MySQL view bin log and recover data