booleen
booleen
  • 发布:2025-02-28 00:13
  • 更新:2025-02-28 00:13
  • 阅读:13

我把对象JSON.parse(JSON.string()) 了,还说没法修改它的数据类型

分类:uni-app x

‌error: java.lang.ClassCastException: uni.UNIC2451D5.DataReactiveObject cannot be cast to io.dcloud.uts.UTSJSONObject‌
00:02:56.925 at uni_modules/xiaoming-form/components/xiaoming-form/xiaoming-form.uvue:63:1
00:02:56.925 61 | }
00:02:56.925 62 |
00:02:56.925 63 | const modelx=new UTSJSONObject(JSON.stringify(props.model));

因为privode不允许传递响应式数据

const modelx=new UTSJSONObject(JSON.stringify(props.model));//为何这里还会报错
const rulesx=JSON.parse(JSON.stringify(props.rules)) as UTSJSONObject;
provide('el-form', {
model: modelx,
rules: rulesx,
addItem,
removeItem
} as ElFormContext)

###################################
这样也不行,虽然文档说可行!!!!!
https://doc.dcloud.net.cn/uni-app-x/uts/buildin-object-api/utsjsonobject.html
#####################################

const modelx=JSON.parse<UTSJSONObject>(JSON.stringify(props.model)!);
const rulesx=JSON.parse<UTSJSONObject>(JSON.stringify(props.rules)!);

2025-02-28 00:13 负责人:无 分享
已邀请:

要回复问题请先登录注册