当前位置:网站首页>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>
边栏推荐
- Milkdown 控件图标
- Realbasicvsr test pictures and videos
- Show the mathematical formula in El table
- [learning notes] zkw segment tree
- Read PG in data warehouse in one article_ stat
- Storage principle inside mongodb
- Digital IC Design SPI
- mysql 局域网内访问不到的问题
- LeetCode_ Binary search_ Medium_ 153. Find the minimum value in the rotation sort array
- Server to server (S2S) event (adjust)
猜你喜欢

将数学公式在el-table里面展示出来

Analysis of DHCP dynamic host setting protocol

聊聊伪共享

QQ的药,腾讯的票

Show the mathematical formula in El table

Vscode编辑器ESP32头文件波浪线不跳转彻底解决
![[dark horse morning post] Huawei refutes rumors about](/img/d7/4671b5a74317a8f87ffd36be2b34e1.jpg)
[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

Fast development board pinctrl and GPIO subsystem experiment for itop-imx6ull - modify the device tree file

MySQL error 28 and solution

室內ROS機器人導航調試記錄(膨脹半徑的選取經驗)
随机推荐
学习突围2 - 关于高效学习的方法
Final review notes of single chip microcomputer principle
靠卖概念上市,认养一头牛能走多远?
Solve the cache breakdown problem
Problems that cannot be accessed in MySQL LAN
PAcP learning note 1: programming with pcap
Milkdown 控件图标
User management summary of mongodb
Introduction and basic use of stored procedures
DETR介绍
Digital IC Design SPI
抓细抓实抓好安全生产各项工作 全力确保人民群众生命财产安全
How far can it go to adopt a cow by selling the concept to the market?
Esp32 series column
Mongodb command summary
Some principles of mongodb optimization
单片机学习笔记之点亮led 灯
Summary of import, export, backup and recovery of mongodb
My "troublesome" subordinates after 00: not bad for money, against leaders, and resist overtime
OSI 七层模型