最近在项目开发中用到了element-ui 的dialog对话框,需要在弹出对话框前对页面信息进行校验,只有通过校验才能弹出,否则返回提示信息的需求,实现方法有很多,在此记录下我的实现办法。
element-ui dialog 官方示例如下:
<el-button type="text" @click="centerDialogVisible = true">打开 Dialog</el-button>
<el-dialog
title="提示"
:visible.sync="centerDialogVisible"
width="30%"
center>
<span>需要注意的是内容是默认不居中的</span>
<span slot="footer" class="dialog-footer">
<el-button @click="centerDialogVisible = false">取 消</el-button>
<el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
</span>
</el-dialog>
<script>
export default {
data() {
return {
centerDialogVisible: false
};
}
};
</script>