Function Description:
Click “add” to add a line; Select a line and click Delete to delete it.
Question:
Click Delete to split only the model bound array to remove the array elements, and then click OK to validate the form and submit it normally; If you click Delete to split the array and directly call the function bound by the OK button to submit the form, the above error will be prompted during form verification and cannot be submitted normally. [Note: the code is not pasted completely, only the important part is pasted]
/*Delete*/
delete(){
this.form.params.splice(this.currentIndex, 1);
this.currentIndex= this.form.params.length - 1;
this.submitForm();
}
/* Form Submission Method*/
submitForm(){
this.$refs["from"].validate((valid) => {
if (valid) {
update(this.from).then(response => {
alert("Submit Successfully");
});
}
})
}
reason:
In the delete method, the form is submitted after the splice. Because the change of the array has not been rendered, the submitted form is still before the splice, so an error is reported.
Solution:
Use promise().then() to put the call to the form submission in the then, so that it can be guaranteed to be submitted after rendering.
Read More:
- Please transfer a valid prop path to form item
- [Vue warn]Error in mounted hook: “Error: please transfer a valid prop path to form item“
- [Vue warn]: Error in mounted hook: “Error: please transfer a valid prop path to form item“
- [Solved] Error in mounted hook: “Error: please transfer a valid prop
- [Solved] Error in event handler for “el.form.blur“: “RangeError: Maximum call stack size exceeded“
- Vue form validate error: Error in v-on handler “TypeError Cannot read properties of undefined (reading ‘indexOf‘)
- Vue3.0 error: Failed to resolve component el-form-item (el element to be unable to be displayed)
- [Solved] Invalid prop: type check failed for prop “modelValue“. Expected Number…
- [Vue warn]: Invalid prop: type check failed for prop [How to Solve]
- [Vue warn]: Invalid prop: custom validator check failed for prop “navigationBarTextStyle“.
- The page console error [Vue warn]: Invalid prop: custom validator check failed for prop “status“
- [Solved] Invalid prop: type check failed for prop “index“. Expected String, got Undefined
- [Vue warn]: Invalid prop: type check failed for prop “index“. Expected String, got Undefined
- [Vue warn]: Invalid prop: custom validator check failed for prop “index“
- [Solved] Vue Element Date plug-in reports an error in form validation
- [Solved] Error in v-on handler “TypeError Cannot read properties of undefined (reading ‘resetFields‘)“
- [Solved] vue.esm.js?efeb:591 [Vue warn]: Error in event handler for “click“: “TypeError: Cannot read property
- How to Solve VUE Error: Avoid mutating a prop directly since the value will be overwritten …
- [Solved] Vue element UI form verification error: cannot read property ‘validate’ of undefined
- [Solved] Vue3 Error: Cannot use ‘in‘ operator to search for ‘path‘ in undefined