在父组件中引用
html:定义 dialogV: false,
sync结合字组件$emit 不写会发现点击一次弹出后,就无法点击第二次,关闭是也会报错
<Dialog :dialogV.sync="dialogV" @handChang="visChang"></Dialog>
js代码:
import Dialog from "./component/dialog";
子组件
<el-dialog title="添加喵咪优选商品展示" :visible.sync="dialogV" width="86%" :before-close="handleClose" center>
<div></div>
<span slot="footer" class="dialog-footer">
<el-button @click="fasGood">取 消</el-button>
<el-button type="primary" @click="addgood">确 定</el-button>
</span>
</el-dialog>
<script>
props: {
dialogV: {
type: Boolean,
default: false
},
dialogVisible: this.dialogV,
},
methods:{
handleClose(done) {
this.$confirm("确认关闭?")
.then(_ => {
this.$emit("handChang", false);
})
.catch(_ => {});
},
}
</script>