使用watch 监听子组件弹框打开时带数据
<template>
<el-dialog :visible="show">
</template>
<!--根据打开弹框的布尔判断:show-->
<script>
export defailt {
<!--子组件接收show-->
props: {
show: {
type: Boolean,
default: false
}
},
watch: {
<!--打开弹框时带数据-->
show(val) {
if (val) {
this.getCrmShortMsgTemplateQueryAllNormal();
}
}
},
methods: {
getCrmShortMsgTemplateQueryAllNormal() {
// 查询所有正常状态的短信模板
crmShortMsgTemplateQueryAllNormal({}).then(res => {
res.data.map(val => {
return this.msgNormal.push({
id: val.id,
name: val.name,
content: val.content
});
});
});
},
}
</script>