1.首先在<template>元素中编写所需的元素,常用 button 按钮,单击按钮显示弹窗
<el-button type="primary" @click="dialogVisible = true">单击</el-button>
2.添加弹窗dialog
<el-dialog title="提示" :visible.sync="dialogVisible" width="30%" :before-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>
3.在data的return中定义初始值,false不显示
data() {
return {
dialogVisible: false
}
}
只是简单的理解,若有错误还望谅解指正!