Element form method resetfields() error
Codes:
// Form Reset
export function resetForm(refName) {
// The purpose of adding the if condition is to solve the problem of non-existent objects in the console
if (this.$refs[refName] ) {
this.$refs[refName].resetFields();
}
}
// Form Reset
export function resetForm(refName) {
// The purpose of adding the if condition is to solve the problem of non-existent objects in the console
if (this.$refs[refName] ) {
this.$refs[refName].resetFields();
}
}
// Form Reset export function resetForm(refName) { // The purpose of adding the if condition is to solve the problem of non-existent objects in the console if (this.$refs[refName] ) { this.$refs[refName].resetFields(); } }
Error Messages:
vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read properties of undefined (reading 'indexOf')
at VueComponent.resetField (element-ui.common.js?5c96:23528)
at eval (element-ui.common.js?5c96:22945)
at Array.forEach (<anonymous>)
at VueComponent.resetFields (element-ui.common.js?5c96:22944)
at VueComponent.resetForm (ruoyi.js?c38a:51)
at VueComponent.reset (index.vue?6ced:2165)
at VueComponent.handleCopy (index.vue?6ced:2504)
at click (index.vue?e6ab:1003)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
at VueComponent.invoker (vue.runtime.esm.js?2b0e:2179)
vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read properties of undefined (reading 'indexOf')
at VueComponent.resetField (element-ui.common.js?5c96:23528)
at eval (element-ui.common.js?5c96:22945)
at Array.forEach (<anonymous>)
at VueComponent.resetFields (element-ui.common.js?5c96:22944)
at VueComponent.resetForm (ruoyi.js?c38a:51)
at VueComponent.reset (index.vue?6ced:2165)
at VueComponent.handleCopy (index.vue?6ced:2504)
at click (index.vue?e6ab:1003)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
at VueComponent.invoker (vue.runtime.esm.js?2b0e:2179)
vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read properties of undefined (reading 'indexOf') at VueComponent.resetField (element-ui.common.js?5c96:23528) at eval (element-ui.common.js?5c96:22945) at Array.forEach (<anonymous>) at VueComponent.resetFields (element-ui.common.js?5c96:22944) at VueComponent.resetForm (ruoyi.js?c38a:51) at VueComponent.reset (index.vue?6ced:2165) at VueComponent.handleCopy (index.vue?6ced:2504) at click (index.vue?e6ab:1003) at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854) at VueComponent.invoker (vue.runtime.esm.js?2b0e:2179)
Solution:
// Form reset
export function resetForm(refName) {
// The purpose of adding the if condition is to solve the problem of non-existent objects in the console
if (this.$refs[refName] !== undefined) {
this.$refs[refName].resetFields();
}
}
// Form reset
export function resetForm(refName) {
// The purpose of adding the if condition is to solve the problem of non-existent objects in the console
if (this.$refs[refName] !== undefined) {
this.$refs[refName].resetFields();
}
}
// Form reset export function resetForm(refName) { // The purpose of adding the if condition is to solve the problem of non-existent objects in the console if (this.$refs[refName] !== undefined) { this.$refs[refName].resetFields(); } }
Another possibility for this type of problem is that the prop is not assigned a value, and a similar problem can occur:
<el-form-item label="Self-pickup offer">
<el-input
v-model="form.selfOffer"
:clearable="true"
:disabled="disabled"
placeholder="Please enter a discount price"
@input="inputCityFloat"
>
<template slot="append">Yuan</template>
</el-input>
</el-form-item>
<el-form-item label="Self-pickup offer">
<el-input
v-model="form.selfOffer"
:clearable="true"
:disabled="disabled"
placeholder="Please enter a discount price"
@input="inputCityFloat"
>
<template slot="append">Yuan</template>
</el-input>
</el-form-item>
<el-form-item label="Self-pickup offer"> <el-input v-model="form.selfOffer" :clearable="true" :disabled="disabled" placeholder="Please enter a discount price" @input="inputCityFloat" > <template slot="append">Yuan</template> </el-input> </el-form-item>
Read More:
- [Solved] Element form method Error: TypeError: Cannot read properties of undefined (reading ‘resetFields’)
- Vue form validate error: Error in v-on handler “TypeError Cannot read properties of undefined (reading ‘indexOf‘)
- [Solved] Error in v-on handler “TypeError Cannot read properties of undefined (reading ‘resetFields‘)“
- [Solved] Vue Project Error: “TypeError: Cannot read properties of undefined (reading ‘init‘)“
- [Solved] Vue element UI form verification error: cannot read property ‘validate’ of undefined
- [Solved] vue.esm.js?efeb:591 [Vue warn]: Error in event handler for “click“: “TypeError: Cannot read property
- [Solved] Vue3 Import element UI error: Uncaught TypeError: Cannot read properties of underfined…
- [Solved] VUE Error: Error in mounted hook: “TypeError: Cannot read properties of undefined (reading ‘$on‘)“
- [Solved] react Chrome Browser Error: Uncaught TypeError: Cannot read properties of undefined (reading ‘forEach‘)
- [Solved] Cannot read properties of undefined (reading ‘propsData‘)“
- [Solved] vue watch Error: Error in callback for watcher “xxx“: “TypeError: Cannot read properties of undefined …
- [Solved] Echarts Error: TypeError: Cannot read properties of null (reading getAttribute )
- [Vue warn]: Error in render: “TypeError: Cannot read properties of undefined
- [Vue warn]: Error in render: “TypeError: Cannot read properties of undefined
- [Solved] electron Use remote Error: Cannot read properties of undefined (reading ‘BrowserWindow‘)
- [Solved] Binding onclick event in JS: for loop: error uncaught typeerror: cannot set properties of undefined (setting ‘classname’)
- [Solved] Vue Element Date plug-in reports an error in form validation
- [Solved] Vue Error: Syntax Error: TypeError: Cannot set properties of undefined (setting ‘XXX’)
- [Solved] TYPEERROR: CANNOT READ PROPERTY ‘REDUCE‘ OF UNDEFINED
- [Solved] Vue Error: TypeError: Cannot read property ‘end‘ of undefined