vue prop 会接收不同的数据类型,这里列出了 常用的数据类型的设置默认值的写法,其中包含: Number, String, Boolean, Array, Object , Function
//数值型
num: {
type: Number,
default: 0
},
//字符串
name: {
type: String,
default: ''
},
//布尔值
dataLoading: {
type: Boolean,
default: false
},
//数组
list: {
type: Array,
default: () => {
return []
}
},
//对象
obj: {
type: Object,
default: () => ({})
},
//方法
getParams: {
type: Function,
default: () => () => {}
}