当前位置:网站首页>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>
边栏推荐
- Some principles of mongodb optimization
- JNA learning notes 1: Concepts
- MySQL入门尝鲜
- How far can it go to adopt a cow by selling the concept to the market?
- 单片机学习笔记之点亮led 灯
- 抓细抓实抓好安全生产各项工作 全力确保人民群众生命财产安全
- shell 批量文件名(不含扩展名)小写改大写
- Enregistrement de la navigation et de la mise en service du robot ROS intérieur (expérience de sélection du rayon de dilatation)
- Ogre入门尝鲜
- Mongodb slice summary
猜你喜欢

线程池拒绝策略最佳实践

Esp32 ① compilation environment

DETR介绍

JS slow motion animation principle teaching (super detail)

Enregistrement de la navigation et de la mise en service du robot ROS intérieur (expérience de sélection du rayon de dilatation)

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

ESP32 ① 编译环境

Custom thread pool rejection policy

Final review notes of single chip microcomputer principle

如何让join跑得更快?
随机推荐
Vscode编辑器ESP32头文件波浪线不跳转彻底解决
Mongodb command summary
工具箱之 IKVM.NET 项目新进展
将数学公式在el-table里面展示出来
Centso7 OpenSSL error Verify return code: 20 (unable to get local issuer certificate)
MongoDB命令汇总
Storage principle inside mongodb
JS判断一个对象是否为空
MongoDB的导入导出、备份恢复总结
LED light of single chip microcomputer learning notes
DETR介绍
DrawerLayout禁止侧滑显示
分布式事务解决方案
Go language learning notes - structure
My "troublesome" subordinates after 00: not bad for money, against leaders, and resist overtime
ROS机器人更换新雷达需要重新配置哪些参数
Esp32 series column
MongoDB 遇见 spark(进行整合)
Mongodb slice summary
Cloud detection 2020: self attention generation countermeasure network for cloud detection in high-resolution remote sensing images