Vue el-dialog 动态修改 title 值
1. 定义一个el-dialog,设置“:title”
--------------注意title前面需要加冒号--------------
<!-- 新增 编辑 窗口 --> <el-dialog :title="dialogTitle" :visible.sync="dialogVisible"> </el-dialog>
2. 初始化变量( 定义 dialogTitle 变量 )
export default {
name: '',
components: {},
props: {},
data() {
return {
dialogTitle:'',//对话框标题
dialogVisible: false,//是否显示新增窗口
addForm: [],
addLoading: false,
3. 在对应需要触发当前对话框之间对变量进行赋值
<el-button type="primary" icon="el-icon-plus" class="form-btn" @click="addRow()">添加</el-button> <el-button size="mini" class="operation-btn" round @click="handleEdit(scope.$index, scope.row)" >编辑</el-button>
//新增数据 addRow() { this.dialogTitle='新增'; this.dialogVisible = true; },
//编辑数据-------------------------------------------------------- handleEdit(index, row) { console.log("handleEdit index:"+index+" name:"+row.name); this.dialogTitle='编辑'; this.dialogVisible = true; },