Error in callback for watcher "options": "TypeError: Cannot read property 'level' of null TypeError

弄了一个动态cascader级联选择器,发现切换数据源的时候报错,网上看到这个文章完美解决https://blog.csdn.net/weixin_43043994/article/details/100303097

问题怎么出现的上面文章写的很清楚,解决方法就是重新加载组件。两个方法一个加v-if,一个加key


<template>
   <el-cascader
                 :options="dataForType"
                 :key="cascaderKey"
                 :props="props"
                 :show-all-levels="false"
                 filterable
                 v-model="dataRefValue"
                                  
    >
   </el-cascader>
</template>
 
<script>
   export default{
       data(){
          return {
                cascaderKey:1
            }
       },
       watch:{
            //切换数据源
             changeMenu(){
                ++this.cascaderKey
            }
       }
}
</script>

猜你喜欢

转载自blog.csdn.net/qq_36802726/article/details/103129744