1、可以是数组形式(数组形式比较宽松,很不严谨,不推荐)
props: ['goodsItem'],
data: function () {
return {
localGoods: this.goodsItem
}
}
props: ['goodsItem'],
computed: {
normalizedSize: function () {
return this.goodsItem.trim().toLowerCase()
}
}
2、可以是对象形式(强烈推荐,就应该使用这种方法),vue2中和vue3中使用方法没有什么不同
搭配es6的简略写法更香
props: {
dataList: {
type: Object,
default: () => ({
a:1,
b:2
})
}
}
vue3demo:
export default {
props: {
listSubProject: {
type: Array,
default: () => [],
},
isPm: {
type: Boolean,
default: false,
},
},
emits: ["evtEdit", "evtDetail", "evtDelete"],
setup(props, { emit }) { }