[Solved] TypeError: Cannot read property ‘indexOf‘ of undefined at VueComponent.resetFields

When you click the empty form button, an error will be reported because the form contains values that are not found;

For example, when active = 1, the prop of El form item is bound to username; When active = 2, prop binds gender;

When active = 1, the form contains username and gender, and gender is not displayed on the page. When the form is cleared, all values in the form will be cleared, and the gender field cannot be found, so an error is reported;

 

Solution:

Replace the resetfields provided with element with each item in the form as the initial value;

For example:

reset(formName){
this.form.username='',
this.form.gender=''
  this.$nextTick(() => {
        this.$refs[formName].clearValidate(); //To clear the checksum prompt
      
      });
}

Read More: