@vue/shared 3.4.21 以上版本 Cannot assign to read only property '\_' of object '#<Object>'
@vue/shared 3.4.21 以上版本 Cannot assign to read only property ‘_’ of object ‘#<Object>’
| 开发环境 | 版本号 | 项目创建方式 |
|---|---|---|
| Windows | 11 | HBuilderX |
示例代码:
异常代码
const initSlots = (instance, children) => {
if (instance.vnode.shapeFlag & 32) {
const type = children._;
if (type) {
instance.slots = toRaw(children);
shared.def(children, "_", type);
} else {
normalizeObjectSlots(
children,
instance.slots = {});
}
} else {
instance.slots = {};
if (children) {
normalizeVNodeSlots(instance, children);
}
}
shared.def(instance.slots, InternalObjectKey, 1);
};
uni-app-vue 正常代码
// uni-app-vue 中加了一个参数,就是正常的
shared.def(children, "_", type, true);
## 操作步骤:
@dcloudio/uni-h5-vue 3.0.0-4040520250104002 + vue 3.5.13
## 预期结果:
正常
## 实际结果:
启动报错 Cannot assign to read only property ‘_’ of object ‘#<Object>’
## bug描述:
使用 vue3.4.21 以上的版本时,报错 Cannot assign to read only property ‘_’ of object ‘#<Object>’,原因来自 @dcloudio/uni-h5-vue 和 @vue/shared
8 回复
你是用到了 @vue/shared 下面的方法引起的报错,还是uniapp内部的代码引起的报错?
使用vue 3.4.21有问题吗?
回复 DCloud_UNI_JBB: 3.4.21没问题
回复 1***@163.com: vue版本最好和uniapp内部依赖的版本保持一致
回复 DCloud_UNI_JBB: 这个问题是否会解决?
一样的报错,updateSlots

什么版本的vue


