当前位置:网站首页>Toraw and markraw
Toraw and markraw
2022-07-07 13:31:00 【The sea is only dark blue】
toRaw Will a reactive Turn the generated responsive object into a normal object
markRaw Mark an object , So that it will never be a responsive object again
vue3 in , use ref、reactive Defining data , In order to put ordinary data , Become responsive data
Some of the time , You need to put responsive data , And then become ordinary data , Use... At this time toRaw
<script lang="ts" setup>
import {
ref, reactive, toRaw, markRaw } from 'vue'
const person = reactive({
name: ' ha-ha ',
age: 10,
job: {
salary: 20
}
})
console.log(person) // proxy Responsive data
const p = toRaw(person)
console.log(p) // object Common data
const sum = ref(0)
const s = toRaw(sum)
console.log(s) // undefined because toRaw Can only handle reactive Defined responsive data
</script>
setup Throughout the work , Call it once ;
When the need has been defined reactive When adding an attribute to the data , This attribute will also become responsive , But if I add it, I don't want it to become responsive , use markRaw
<script lang="ts" setup>
import {
ref, reactive, toRaw, markRaw } from 'vue'
const person = reactive({
name: ' ha-ha ',
age: 10,
job: {
salary: 20
}
})
let car = {
name: ' automobile ', price: 40 }
person.car = markRaw(car) // here ,person It added car It's normal data
</script>
边栏推荐
- PACP学习笔记三:PCAP方法说明
- PAcP learning note 3: pcap method description
- 实现IP地址归属地显示功能、号码归属地查询
- Fast development board pinctrl and GPIO subsystem experiment for itop-imx6ull - modify the device tree file
- LeetCode_二分搜索_中等_153.寻找旋转排序数组中的最小值
- Shell batch file name (excluding extension) lowercase to uppercase
- Problems that cannot be accessed in MySQL LAN
- Vscade editor esp32 header file wavy line does not jump completely solved
- Introduction and basic use of stored procedures
- Custom thread pool rejection policy
猜你喜欢

MySQL error 28 and solution

Centso7 OpenSSL error Verify return code: 20 (unable to get local issuer certificate)

Vscode编辑器ESP32头文件波浪线不跳转彻底解决

QQ medicine, Tencent ticket
![Scripy tutorial classic practice [New Concept English]](/img/bc/f1ef8b6de6bfb6afcdfb0d45541c72.png)
Scripy tutorial classic practice [New Concept English]
![[Presto profile series] timeline use](/img/c6/83c4fdc5f001dab34ecf18c022d710.png)
[Presto profile series] timeline use

Storage principle inside mongodb

我那“不好惹”的00后下属:不差钱,怼领导,抵制加班

LIS longest ascending subsequence problem (dynamic programming, greed + dichotomy)

Ogre入门尝鲜
随机推荐
Mongodb command summary
How did Guotai Junan Securities open an account? Is it safe to open an account?
Mongodb replication (replica set) summary
Test next summary
OSI seven layer model
Esp32 construction engineering add components
Esp32 series column
[dark horse morning post] Huawei refutes rumors about "military master" Chen Chunhua; Hengchi 5 has a pre-sale price of 179000 yuan; Jay Chou's new album MV has played more than 100 million in 3 hours
聊聊伪共享
Introduce six open source protocols in detail (instructions for programmers)
[learning notes] agc010
工具箱之 IKVM.NET 项目新进展
Ogre introduction
MongoDB优化的几点原则
Simple and easy-to-use code specification
【黑马早报】华为辟谣“军师”陈春花;恒驰5预售价17.9万元;周杰伦新专辑MV 3小时播放量破亿;法华寺回应万元月薪招人...
抓细抓实抓好安全生产各项工作 全力确保人民群众生命财产安全
线程池拒绝策略最佳实践
Drawerlayout suppress sideslip display
如何让electorn打开的新窗口在window任务栏上面