l***@163.com
l***@163.com
  • 发布:2025-09-09 15:35
  • 更新:2025-09-09 16:09
  • 阅读:25

uni-appx的props是不支持复杂数组吗

分类:uni-app x
type ItemListType = { text : string, color : string, size : number }  

props: {  
simpleList: {  
type: Array as PropType<string[]>,  
default: () => []  
},  
itemList: {  
type: Array as PropType<ItemListType[]>,  
required: true  
},  
}

simpleList可以正常v-for循环,itemList循环不了,抛出异常error: java.lang.ClassCastException: uni.UNID206DCB.ItemListType1ReactiveObject cannot be cast to uni.UNID206DCB.ItemListType‌

2025-09-09 15:35 负责人:无 分享
已邀请:
l***@163.com

l***@163.com (作者)

解决了,要使用UTSJSONObject[],貌似不能使用自定义的类型

itemList: {  
type: Array as PropType<UTSJSONObject[]>,  
required: true  
},

要回复问题请先登录注册