当前位置:网站首页>04. Default value of toref
04. Default value of toref
2022-07-28 22:06:00 【@Move to the world】
This lesson , Let's take a look toRef The default value of .
We know toRef Can be used for a source responsive object property Create a new ref, then ref Can be delivered , It will stay focused on its source property Responsive connection for .
<script setup>
import { reactive, toRef } from 'vue'
const state = reactive({
foo: 1,
bar: 2,
})
const fooRef = toRef(state, 'foo')
fooRef.value++
console.log(state.foo) // 2
state.foo++
console.log(fooRef.value) // 3
</script>
Here we are state Object's foo Property to create a named fooRef Of ref, When we fooRef.value++ when , here state.foo The value of also changes , because toRef Will maintain the response connection to its source object properties , therefore , When state.foo When the value changes ,fooRef The value of will change .
These points , I'm sure you all know that .
but toRef You can also provide a default value , This point may be relatively rare .
Let's take an example , Suppose we want to be state Object's car Property to create a named carRef Of ref,
边栏推荐
- 记录Flutter解决A RenderFlex overflowed by 7.3 pixels on the bottom溢出问题
- Explain the remote debugging program of visual studio 2015 in LAN
- 为什么 0.1 + 0.2 不等于0.3?如何解决这个问题?
- 第 7 篇:绘制旋转立方体
- HYDAC溢流阀DB08A-01-C-N-500V
- Embrace open source guidelines
- HCIA综合实验(以华为eNSP为例)
- Two global variables__ Dirname and__ Further introduction to common functions of filename and FS modules
- typeof原理
- The University was abandoned for three years, the senior taught himself for seven months, and found a 12K job
猜你喜欢

For the first time, Chinese scientists used DNA to construct convolutional artificial neural network, which can complete 32 types of molecular pattern recognition tasks, or be used for biomarker signa

第 8 篇:创建摄像机类

Openeuler embedded sig | distributed soft bus

Save 70% of the video memory and increase the training speed by 2 times! Zheda & Ali proposed online convolution re parameterization orepa, and the code has been open source! (CVPR 2022 )

搞事摸鱼一天有一天

Professional Committee of agricultural water and soil engineering of China Association of Agricultural Engineering - 12th session - Notes

Official document of kubevela 1.4.x

Data interpolation -- normalize data of different magnitude

Byte side: can TCP and UDP use the same port?

Msfvenom makes master and controlled terminals
随机推荐
What technology is needed for applet development
40. 组合总和 II
Skiasharp's WPF self drawn drag ball (case version)
Open earphone which air conduction earphone with good sound quality and recognized sound quality is recommended
display 各值的区别
Detailed explanation of JVM memory layout (glory collection version)
纳米金偶联抗体/蛋白试剂盒(20nm,1mg/100μg/500 μg偶联量)的制备
The applet listens for the target node to appear on the screen
[hero planet July training leetcode problem solving daily] dynamic planning on the 28th
Chinese patent keyword extraction based on LSTM and logistic regression
分而治之,大型文件分片上传
I have been in the industry for 4 years and changed jobs twice. I have understood the field of software testing~
get和post的区别
微信小程序开发公司你懂得选择吗?
04.toRef 默认值
Aimbetter insight into your database, DPM and APM solutions
Wechat applet development company, do you know how to choose?
Official document of kubevela 1.4.x
[machine learning] naive Bayesian classification of text -- Classification of people's names and countries
迪赛智慧数——折线图(堆叠面积图):2022年不同职业人群存款额占月收入比例排名