In element dynamically loaded el-cascader

页面<el-cascader
v-model="partyOrganId"
:placeholder="partyOrganName"
:props="prop"
:show-all-levels="false"
class="font_pla"
></el-cascader>

 

Data () {
return {
partyOrganId: [],
prop: {
the lazy: to true,
lazyload (Node, Resolve) {
the setTimeout (() => {
IF (node.level == 0) {
Axios ({
Method: "GET" // mode request
url: "/ api / commonUser / findByChildRegion", // request address
the params: {
regionCode: "330000"
}
})
.then (RES => {
const Cities res.data.data.map = (( value, I) => ({
value: value.regionCode,
label: value.regionName,
Leaf: node.level> = 2
}));
// child node data returned by a call to resolve, notification component data loaded
resolve ( Cities);
})
.catch (ERR => {
the console.log (ERR);
});
}
IF (node.level ==. 1) {
Axios ({
Method: "GET", // mode request
url: "/ api / commonUser / findByChildRegion", // request address
the params: {
regionCode: node.value
}
})
. the then (RES => {
const Areas res.data.data.map = ((value, I) => ({
value: value.regionCode,
label: value.regionName,
Leaf: node.level> = 2
}));
// child node data returned by a call to resolve, notification component data loaded
Resolve (Areas);
})
.catch (ERR => {
the console.log (ERR);
});
} the else IF (node.level == 2 ) {
Axios ({
Method: "GET", // mode request
url: "/ api / commonPartyOrgan / getPartyOrganInfo", // request address
the params: {
cityCode:node.path[0],
areaCode is: node.path [. 1]
}
})
.then (RES => {
const res.data.data.map the partys = ((value, I) => ({
value: value.id,
label: value.name,
Leaf: node.level> = 2
}));
// child node data returned by a call to resolve, notification component data loaded
Resolve (the partys);
})
.catch (ERR => {
the console.log (ERR);
} );
}
}, 1000);
}
}
};
},

Guess you like

Origin www.cnblogs.com/yyjspace/p/11599038.html