用 nextTick 处理一下form的数据:
this.$nextTick(() => {
this.student = student;
})
然后在关闭dialog 时调用重置方法:
this.$refs[student].resetFields();
完整代码:
<el-dialog title="添加学生信息" :visible.sync="dialogFormVisible" width="32%" :center="true" top="20px">
<el-form :model="student" ref="student">
<el-form-item label="姓名" :label-width="formLabelWidth" >
<div slot="footer" class="dialog-footer">i
<el-button @click="resetForm('student')">重置</el-button>
</div>
</el-form>
</el-dialog>
resetForm(student) {
this.$nextTick(() => {
this.student = student;
})
this.$refs[student].resetFields();
//this.$refs[student] 获取表单
//resetFields() 重置表单为空
}