The editor also shares with you the corresponding problems of data in Vue3. Let's take an example like this Vue.createApp({ template: `<div>{{ nameObj.name }}</div>`, setup() { const { reactive } = Vue const nameObj = reactive({name:'lilei',age:18}) setTimeout(() => { nameObj.name = 'hanmeimei' },2000) return { nameObj } } }).mount('#root') At this point, we may think of the content about destructuring assignment in Vue.createApp({ template: `<div>{{ name }}</div>`, setup() { const { reactive, toRefs } = Vue const nameObj = reactive({name:'lilei',age:18}) let { name } = nameObj setTimeout(() => { name.value = 'hanmeimei' },2000) return { name } } }).mount('#root') In actual operation, we found that the content on the page did not become Vue.createApp({ template: `<div>{{ name }}</div>`, setup() { const { reactive, toRefs } = Vue const nameObj = reactive({name:'lilei',age:18}) let { name } = toRefs(nameObj) setTimeout(() => { name.value = 'hanmeimei' },2000) return { name } } }).mount('#root') Similarly, Vue.createApp({ template: `<div>{{ age }}</div>`, setup() { const { reactive, toRef } = Vue const nameObj = reactive({name:'lilei'}) let age = toRef(nameObj,'age') setTimeout(() => { age.value = 'hanmeimei' },2000) return { age } } }).mount('#root') This is the end of this article about the details of Refs and Ref in Vue3. For more relevant content about Refs and Ref in Vue3, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Code for aligning form checkbox and radio text
>>: Problems installing TensorRT in docker container
Sometimes we need to import some data from anothe...
Table of contents Preface 1. Object.freeze() 2. O...
Table of contents Typical waterfall website Water...
Preface This article mainly introduces the use an...
I have found a lot of online resources on this pro...
When we perform automatic discovery, there is alw...
Table of contents 01 CMD 02 ENTRYPOINT 03 WORKDIR...
I don't know if you have used the frameset at...
Without further ado, these three methods are: ren...
How to display text overflow? What are your needs...
1. Compile and install ovs from source code: Inst...
Introduction to kubectl kubectl is a command line...
See the effect first Implementation Code <div ...
Table of contents 1. Container service update and...
Preface Recently, our company has configured mbp,...