问题描述:Vue--Props with type Object/Array must use a factory function to return the default value.
// 报错代码
props: {
list: {
type: Array,
default:[]
}
},
解决办法:
// 正解1 箭头函数
props: {
list: {
type: Array,
default:()=>[]
}
}
// 正解2
props: {
cartList: {
type: Array,
default:function(){
return [];
}
}
},
props: {
vModel: {
type: Array,
default: () => [],
},
},
data() {
return {
model: this.vModel
}
},