一。在components文件中新建 弹框组件
<template> <div> <el-dialog title="提示" :visible.sync="dialogVisible" width="30%" @close="handleClose"> <span>这是一段信息</span> <span slot="footer" class="dialog-footer"> <el-button @click="dialogVisible = false">取 消</el-button> <el-button type="primary" @click="dialogVisible = false">确 定</el-button> </span> </el-dialog> </div> </template> <script> export default { props:{ DialogFlag: { default: false } }, data(){ return{ dialogVisible: false } }, watch:{ DialogFlag(){ this.dialogVisible = this.DialogFlag } }, methods:{ handleClose() { this.$emit('update:DialogFlag',false) } }, } </script>
二。在需要用到的组件中引入子组件
<account-inform-add :DialogFlag.sync="DialogFlag"></account-inform-add>methods: { addAccountInform(){ this.DialogFlag = true } }
标签:vue,false,methods,elementui,DialogFlag,弹框,组件 From: https://www.cnblogs.com/anna001/p/16948667.html