element-UI对话框标题title属性和vue自定义绑定
1.弹出框动态绑定标题:title<el-dialog :title="titleMap[dialogStatus]" :visible.sync="dialogFormVisible" :rules="rules" ref="ruleForm"><el-form><el-form-item label="角色" :label-width="formLabelWidt
·
1.弹出框动态绑定标题:title
<el-dialog :title="titleMap[dialogStatus]" :visible.sync="dialogFormVisible" :rules="rules" ref="ruleForm">
<el-form>
<el-form-item label="角色" :label-width="formLabelWidth" :rules="[{ required: true, message: '输入角色名', trigger: 'blur' }]">
<el-input v-model="form.roleName" auto-complete="off" style="width: 300px;"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancel">取 消</el-button>
<el-button type="primary" @click="update('ruleForm')">确 定</el-button>
</div>
</el-dialog>
2.在data中定义
titleMap: {
addEquipment: '新增角色', //根据自己内容定义名字
editEquipment: "编辑角色" //根据自己内容定义名字
},
//新增和编辑弹框标题
dialogStatus: "",
3.在methods中你新增和编辑的绑定的方法中添加如下
//新增
add() {
this.dialogStatus = "addEquipment";
this.dialogFormVisible = true
},
//编辑
handleEdit() {
this.dialogFormVisible = true
this.dialogStatus = "editEquipment"
},
更多推荐
已为社区贡献1条内容
所有评论(0)