import { getAllList } from "@src/render/api/region/region"
import { getAllList } from "@src/render/api/region/region"
data() {
return {
options: []
}
},
getAllListRequest() {
this.options = []
getAllList()
.then(res => {
let { list } = res.data
this.options = this.switchData(list)
console.log(this.options, "省市区")
})
.catch(err => {})
},
// 处理 地理 数据 格式
switchData(list) {
let data = []
if (list && list.length > 0) {
list.forEach(item => {
let obj = {
...item,
value: item.name,
label: item.name
}
if (item.children && item.children.length > 0) {
obj.children = this.switchData(item.children)
}
data.push(obj)
})
}
console.log(data)
return data
},