父组件
<template>
<!-- 商品分类弹窗 -->
<CategoryDialog v-model:categoryVisible="categoryVisible" :cateList="cateList" :categoryIds="form.categoryIds" @onSave="onSaveCategory" />
</template>
子组件
export default defineComponent({
name: 'category-dialog',
props: {
categoryVisible: {
type: Boolean
}
},
data() {
return {
...
} as pageState
},
watch: {
categoryVisible(newVal) {
if (newVal) {
this.selectedCategory = []
this.initCategory()
}
}
},
methods: {
onCancel() {
this.$emit('update:CategoryVisible', false)
},
})