子組件接收父級組件中定義的事件
//父級組件定義update-list事件
<Operate :param="scope.row.id" @update-list="getList()" />
//=============================================
//子組件Operate接收updateList事件 使用駝峰方式書寫
const emits = defineEmits(['updateList']);
//子組件中調(diào)用方法
emits('updateList')
子組件接收參數(shù)
const props = defineProps({
params: {
type: Object,
default: () => { }
},
flag: {
type: Number,
default: 0
}
})
// 動態(tài)數(shù)據(jù)
const { params } = toRefs(props)
子組件向父級暴露函數(shù)
const getUserList = () => {
//.......
}
defineExpose({
getUserList
})
//父級方法中調(diào)用
<Child ref="child" />
.....
const child= ref()
child.value.getUserList()
監(jiān)聽父級參數(shù)
const props = defineProps({
detailInfo: {
type: Object,
default: () => { }
},
})
const { detailInfo } = toRefs(props);
watch([props], () => {
// show.value = true;
console.log(detailInfo.value, 'detailInfo.value');
// if (!detailInfo.value.dealFlag || detailInfo.value.dealFlag == 0) update({ id: detailInfo.value.id, dealFlag: 1 }, 'flag')
});