- 给el-dialog添加@close=“editDialogClosed”,在关闭对话框时会调用这个函数
- 给el-form添加ref=“editFormRef”
- 写函数
// 监听修改文章对话框的关闭事件
editDialogClosed () {
this.$refs.editFormRef.resetFields()
},
还要注意给el-form-item添加prop的值,也就是input绑定的值,
这样在关闭对话框的时候,表单就会进行重置
<el-dialog
title="修改用户"
:visible.sync="editDialogVisible"
@close="editDialogClosed">
<el-form :model="editForm" ref="editFormRef" >
<el-form-item label="更改选项" prop="field">
<el-select v-model="editForm.field" placeholder="请选要更改的参数">
<el-option v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"></el-option>
</el-select>
</el-form-item>
<el-form-item prop="value">
<el-input v-model="editForm.value" placeholder="请输入更改值"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="editDialogVisible = false">取 消</el-button>
<el-button type="primary" @click="editnoteMessage()">确 定</el-button>
</span>
</el-dialog>