Composition API TypeError: Cannot add property xxx, object is not extensible
生活随笔
收集整理的這篇文章主要介紹了
Composition API TypeError: Cannot add property xxx, object is not extensible
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Composition API 創建的對象必須經過初始化,如果對已經創建的對象添加新的屬性,就對出現標題中的錯誤。
const state = reactive({foo: 'bar'}); Reflect.isExtensible(state); // true state.baz = 'this is not allowed'; // 報錯其實Vue僅僅是設置了對象不可擴展而已。這個錯誤本身是js報出的。
'use strict';var obj = {}; Object.preventExtensions(obj);obj.x = 'foo';以上便會拋出該錯誤。但需要是嚴格模式。而現在我們寫的代碼都是ESM的,自然默認就是嚴格模式。
總結
以上是生活随笔為你收集整理的Composition API TypeError: Cannot add property xxx, object is not extensible的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用ssh连接Linux服务器反应慢,配
- 下一篇: 温馨提示--Python小屋刷题神器明天