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
The downloaded version is the Zip decompression v...
MySQL's foreign key constraint is used to est...
This article example shares the specific code of ...
Idea: Just sort randomly first and then group. 1....
We usually use the <ul><li> tags, but ...
Copy code The code is as follows: <span style=...
The reuse of code in vue provides us with mixnis....
Configure web page compression to save resources ...
Preface: Due to my work, I am involved in the fie...
Today, I want to write about a "low-tech&quo...
Table of contents 1. Basic Concepts 2. Developmen...
This article example shares the specific code of ...
When the resolution of the login interface is par...
what is it? GNU Parallel is a shell tool for exec...
Preface This is an investigation caused by the ex...