异步加载不能有多级数据,异步的只能一级级加载
贴上我的代码
html
:load="loadNode"
node-key='id'
lazy
ref="tree"
:default-expanded-keys="[1]"
show-checkbox
>
js
loadNode(node, resolve) {
console.log(node) if (node.level === 0) {
return resolve([{ 'name': '全部',id:1}])
} if(node.data.id == 1){ this.getyiji(resolve) this.total = 1
}
if(node.data.provinceId){ this.geterji(resolve)
}
if(node.data.cityID){ this.getquyu(resolve)
}
if(node.data.areaId){ this.getshequ(resolve)
}
if(node.data.type){ return
}
},
getshequ(resolve){
axios.get('https://www.easy-mock.com/mock/5b21fa62cc17d07388c28b36/example/shequ').then(res=>{
res.data.data.filter(i =>{ i.leaf = true
return
})
let data = res.data.data
resolve(data)
})
},
getquyu(resolve){
axios.get('https://www.easy-mock.com/mock/5b21fa62cc17d07388c28b36/example/quyu').then(res=>{ let data = res.data.data
resolve(data)
})
},
getyiji(resolve){
axios.get('https://www.easy-mock.com/mock/5b21fa62cc17d07388c28b36/example/getJurisdiction').then(res=>{ let data = res.data.data
resolve(data)
})
},