How to convert responsive proxy objects into non-responsive in vue3

A markRaw API introduced in the official document .
Meaning: Mark an object so that it will never be converted to a proxy. Return the object itself.
The following is the official document code description

const foo = markRaw({})
console.log(isReactive(reactive(foo))) // false

// 嵌套在其他响应式对象中时也可以使用
const bar = reactive({ foo })
console.log(isReactive(bar.foo)) // false

Use markRaw to convert responsive proxy objects into non-responsive ones

let foo = markRaw({}) //标记一个对象,使其永远不会转换为 proxy。返回对象本身。
let bar = reactive({ age: '90' }) //响应式的
Object.assign(foo, bar)
console.log(foo, 'foo') //非响应式 { age: '90' }

If there is another better way, welcome to advise

Guess you like

Origin blog.csdn.net/weixin_43485503/article/details/125063792