I got a dynamic cascader cascade selector, and found that an error was reported when switching data sources. I saw this article on the Internet to solve it perfectly. https://blog.csdn.net/weixin_43043994/article/details/100303097
The above article on how the problem occurs is very clear. The solution is to reload the component. Two methods, one with v-if, one with 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>