1.prop屬性值需要與form中的key字段保持性一致
2.當頁面是編輯頁面的時候打開彈框使用
this.$refs.proTypeForm.$refs.checkform.resetFields()的方式調用的話 會發現重置按鈕不生效,具體是由於該方法的底層機制導致
原因是form表單的重置是以第一次打開的數據作為重置標准,如果先打開的是更新,那么重置之后以第一次更新的數據作為標准;
Dialog 中的內容是懶加載的,目前 edit (更新)方法的寫法導致 Form 剛加載出來時值就已經是新的了,所以 resetFields 也只能重置到初始化的頁面值即第一次顯示的數據
解決方法
2.1重寫form表單的resetFields()
resetFields() {
this.$set(this.ruleForm, 'build', '')
this.$set(this.ruleForm, 'buildChild', [])
this.$set(this.ruleForm, 'operate', [])
this.$set(this.ruleForm, 'service', [])
},
2.2在獲取表單數據的的時候利用this.$nextTick()
watch: {
proDataForm: {
handler() {
this.$nextTick(()=>{
this.ruleForm = this.proDataForm
})
},
immediate: true
}
},