1. ElementUI自帶清除表單方法javascript
this.$refs[formName].resetFields(); // 重置表單移除校驗 this.$refs[formName].clearValidate(); // 僅清除驗證
2. 刷新整個頁面java
location.reload();
3. 只須要在From標籤上加上v-if="showDialog"這句代碼,當關閉彈框時showDialog=false,this
再次打開彈框是showDialog置爲true,這樣每次打開彈框它都會生成一個新的表單。code
<Modal v-model="showDialog" :title="modalTitle" :mask-closable="false"> <Form v-if="showDialog" ref="formData" :model="formData" :rules="ruleValidate" label-position="top"> <FormItem label="姓名:" prop="name"> <Input type="text" v-model="formData.name"/> </FormItem> <FormItem label="年齡:" prop="age"> <Input type="text" v-model="formData.age"/> </FormItem> </Form> <div slot="footer"> <Button type="text" @click="cancel('ruleValidate')">取消</Button> <Button type="primary" @click="Save('ruleValidate')">保存</Button> </div> </Modal>
4.在關閉頁面/打開頁面方法對錶單從新賦值爲空orm
參考地址ip