html
<el-form-item class="formitem" label="旅居地区:" prop="livingArea1">
<el-cascader
v-if="!isljdz"
clearable
style="width:90%"
placeholder="可搜索地区"
v-model="hightemporaryform.livingArea1"
:props="props"
filterable
@change="handleChange"
ref="cascader01"
></el-cascader>
<el-input
v-if="isljdz"
style="width:90%"
v-model="hightemporaryform.livingArea1"
@focus="lddddd"
></el-input>
</el-form-item>
data
props: {
lazy: true,
lazyLoad(node, resolve) {
console.log("htp", http);
const { level } = node;
console.log(node);
if (node.level == 0) {
if ("string" == typeof cities) {
cities = JSON.parse(cities);
}
const nodes = cities.map(item => ({
value: item.value,
label: item.label
}));
console.log("nodes0", nodes);
resolve(nodes);
}
if (node.level != 0) {
console.log("node", node);
let formm = { label: node.data.value };
http({
method: "post",
url: `/ohealth/api/v1/system/common/subList`,
data: formm
})
.then(function(response) {
console.log("老方法", response.data.data);
let nodes02 = response.data.data;
const nodesee = nodes02.map(item => ({
value: item.value,
label: item.label,
leaf: item.leaf == 3
}));
console.log("leve2", nodes02);
resolve(nodesee);
})
.catch(function(error) {});
}
}
},
js
目的传字符串
// 户籍地
handleChange02(value, label) {
this.hightemporaryform.householdPlace = this.$refs.cascader02
.getCheckedNodes()[0]
.pathLabels.toString("/");
this.hightemporaryform.householdPlace = this.hightemporaryform.householdPlace.replaceAll(
",",
""
);
this.hightemporaryform.householdPlaceCode = this.$refs.cascader02.getCheckedNodes()[0].value;
},