解决 elementui el-cascader组件懒加载时存在选中状态丢失的问题?
<el-cascader ref="cascader" v-model="curList" :show-all-levels="false" :options="classList":props="cascaderProps"clearablefilterablestyle="width: 100%"placeholder="选择"@change="handleChange"
/>
data(){return{curList:[],classList:[],cascaderProps: {checkStrictly: true,multiple: true,children: 'sonList',value: 'id',label: 'name',leaf: 'leaf',lazy: true,lazyLoad: this.lazyLoadCascader}}
},
methods:{async lazyLoadCascader(node, resolve) {const { checked } = nodeif (node.level === 0) {const list = await this.getClassList(1) this.externalKnowclassList = listthis.initSelectedCascaderdata() node.data = listresolve(list)} else {const { id, type, sonList } = node.dataif (this.$utils.isNotEmptyArray(sonList)) {resolve([])} else {const list = await this.getClassList(type + 1, id) node.data.sonList = listresolve(list)}const cascader = this.$refs.cascadernode.doCheck(checked) cascader.panel.handleExpand(node) cascader.panel.calculateMultiCheckedValue() }},
}