Element UI 一键实现表单置空操作
表单如下:
<el-form ref="form" :model="form" :rules="dataRule" :inline="true" label-width="200px" >
<el-form-item>
<el-button type="primary" style="margin-left: 1350px" icon="el-icon-document-delete" size="mini" @click="clearText">清空</el-button>
</el-form-item>
//省略其余表单组件部分
</el-form>
清空表单函数如下:
methods: {
clearText(){
this.$refs.XXX.resetFields()
} //XXX与表单的ref属性应相同,此处为form
}