Cannot read property ‘resetFields‘ of undefined

引起原因:多个弹框使用同一个页面

百度后解决方法:

1. mouted加载table数据以后,隐藏的弹出框并没有编译渲染进dom里面。

// 清表单的方法中,使用this.$nextTick-更新视图之后回调事件
  resetForm(formName) {
          this.$nextTick(()=>{
             this.$refs[formName].resetFields()
       })                
    },

2.table表单中缺少prop的item还会引起js报错


    	
          
            
          
        
        
          
            
          
        
 

检查所有项,加入prop即可

我的解决办法:

if (this.$refs.dataForm != undefined){
        this.$refs["dataForm"].resetFields();
   }

你可能感兴趣的:(vue.js,elementui,前端)