Demand: Get the districts and villages below the area according to the AREAID in the login information. Each request data is avid every time
<EL-Cascader
v-model = "form.areaid"
: props = "props"
@Change = "handlechange"
Placeholder = "Please select the area"
: Clearable = "TRUE"
: show-all-levels = "false"
Forecast
</El-Cascader>
Data Add
props: {
expandTrigger: "hover",
emitPath: false,
lazy: true,
lazyLoad: this.lazyLoad,
},
Method Methods: {}
lazyload (Node, Resolve) {
this.getdata (node, resolve);
},
getdata (node, resolve) {
let that = this;
Let level = node.level;
const doit = function () {
let arealevel = that.info.arealevel;
// 4 is because there are only 4 layers at all regional levels, so it will dynamically display the number of lower levels
let j = 4 -realevel;
var ID;
if (level == 0) {
id = that.info.id;
} else {
id = node.value;
}
getChildDictarebyid (ID) .then ((res) => {{
var result;
if (level == 0) {
result = res.data;
result.Foreach (item) => {{
item.value = item.id;
item.label = item.areaname;
});
}
if (0 <level <j) {
// There is a problem with the data to show the data in the box only display the last last one
result = res.data;
result.Foreach (item) => {{
item.value = item.id;
item.label = item.areaname;
item.Leaf = level> j -2;
});
}
Resolve (result);
});
};
if (! That.info) {
that.getUserInfo (() => {
doit ();
});
} else {
doit ();
}
},
getUserInfo (callback) {
getinfo ({}). Then ((res) => {
this.info = res.data.dictarea;
});
},
mounted() {
this.getUserInfo();
},
This is the code that I need to change my project after finding a method online, but there is a problem that only the last data is displayed after choosing the region, but there is no too much request for the project. If you know how to change, welcome to leave a message ———————————————