目前项目有一个输入框内容是需要选择行业类型,
按国标分类有门类大类中类小类四项内容,为了避免使用四个input输入框因此采用了elementUI的级联选择器。
然后因为每一小类要在选择了上级类型后调取接口获取数据,因此采用了官方给出的懒加载操作。
实现级联选择很简单
props: {
value: 'BIANMA',
label: 'NAME',
lazy: true,
lazyLoad (node, resolve) {
if (node.path) {
node.path.length == 1 && listindustryMedium(node.path[0]).then(response => {
resolve(response.data);
});
node.path.length == 2 && listindustryMedium(node.path[1]).then(response => {
resolve(response.data);
});
node.path.length == 3 && listindustryMedium(node.path[2]).then(response => {
response.data.forEach(item => {
item.leaf = 'leaf';
})
resolve(response.data);
<