当前位置:网站首页>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>
边栏推荐
- Centso7 OpenSSL error Verify return code: 20 (unable to get local issuer certificate)
- Use of polarscatter function in MATLAB
- MySQL入门尝鲜
- PHP - laravel cache
- Go language learning notes - structure
- MongoDB优化的几点原则
- My "troublesome" subordinates after 00: not bad for money, against leaders, and resist overtime
- Error lnk2019: unresolved external symbol
- [untitled]
- Mongodb replication (replica set) summary
猜你喜欢
室内ROS机器人导航调试记录(膨胀半径的选取经验)
QQ medicine, Tencent ticket
C语言数组相关问题深度理解
Thread pool reject policy best practices
Ogre introduction
Cmake learning and use notes (1)
JS slow motion animation principle teaching (super detail)
Vscode编辑器ESP32头文件波浪线不跳转彻底解决
MongoDB内部的存储原理
[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
随机推荐
MongoDB优化的几点原则
Introduction and basic use of stored procedures
Thread pool reject policy best practices
error LNK2019: 无法解析的外部符号
【等保】云计算安全扩展要求关注的安全目标和实现方式区分原则有哪些?
Fast development board pinctrl and GPIO subsystem experiment for itop-imx6ull - modify the device tree file
Detr introduction
Milkdown 控件图标
MongoDB的导入导出、备份恢复总结
靠卖概念上市,认养一头牛能走多远?
Storage principle inside mongodb
Clion mingw64 Chinese garbled code
Go language learning notes - structure
Isprs2021/ remote sensing image cloud detection: a geographic information driven method and a new large-scale remote sensing cloud / snow detection data set
Ogre入门尝鲜
信号强度(RSSI)知识整理
Esp32 ① compilation environment
[untitled]
JS slow motion animation principle teaching (super detail)
MongoDB 遇见 spark(进行整合)