正常問(wèn)題:
? ? ? ?在el-form標(biāo)簽外的的元素使用resetField()方法未能清除表單數(shù)據(jù),可使用下面的方法:
this.$nextTick(() => {
this.$refs.menuForm.resetFields();
});
介紹bug背景
? ? ? ?在一個(gè)頁(yè)面新增霎匈、編輯使用同一個(gè)dialog框逼争,點(diǎn)擊編輯按鈕編輯的時(shí)候dialog框內(nèi)的表單自動(dòng)賦值table中某行數(shù)據(jù)超凳。
handleClick(row) {
this.dialogVisible = true;
this.form.username = row.username
this.form.password = row.password
}
? ? ? ?在新增的按鈕加上上面帶dom加載完清除表單的方法。
addinfo() {
this.dialogVisible = true;
this.$nextTick(() => {
this.$refs.form.resetFields();
});
}
? ? ? ?但是發(fā)現(xiàn)未能清除掉數(shù)據(jù)靠抑,后發(fā)現(xiàn)在編輯賦值的時(shí)候也需要調(diào)用nextTick()方法賦值偷厦,不然表單仿佛會(huì)認(rèn)定賦值的數(shù)據(jù)是初始數(shù)據(jù)捆愁;
handleClick(row) {
this.dialogVisible = true;
this.$nextTick(() => {
this.form.username = row.username
this.form.password = row.password
})
}