<el-form-item label="选择省/市/区" prop="provinceName">
<el-cascader
:options="provinceList"
:props="{ checkStrictly: true }"
v-model="selectedValue"
clearable
style="width: 240px"
/>
</el-form-item>
provinceList: [],//省市区
selectedValue: [], // 保存选择的省市区值
//省/市/区
async optionsRefer() {
try {
this.loading = true;
const res = await this.api.getData('areaNew/areaList');
const newData = this.convertData(res);
this.provinceList = newData;
} catch (err) {
console.log('省/市/区加载错误,刷新试试...');
}finally {
this.loading = false;
}
},
convertData(data) {
return data.map(province => {
return {
value: province.id,
label: province.name,
children: province.list ? province.list.map(city => {
return {
value: city.id,
label: city.name,
children: city.list ? city.list.map(area => {
return {
value: area.id,
label: area.name
};
}) : []
};
}) : []
};
});
},