vant 级联选择器跳坑
<van-field readonly clickable name="calendar" :value="area" label="户籍区划" required placeholder=""
@click="cityShow = true">
</van-field>
<van-popup v-model="cityShow" position="bottom">
<van-picker @cancel="cityShow = falase" show-toolbar :columns="areaList" @confirm="confirmCity">
</van-picker>
</van-popup>
setarr(item) {
if (!item.children) {
item.text = item.name
return item
} else {
item.text = item.name
item.children.forEach((sitem, sindex) => {
item = this.setarr(sitem)
})
return item
}
},
getareaList() {
var self = this;
let content = {
fun: 'get_base_addr'
}
axios.get('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', {
params: content
})
.then(function (response) {
self.loading = false;
console.log(response.data.result);
response.data.result.forEach((item, index) => {
item = self.setarr(item)
})
console.log(1111, response.data.result)
self.areaList = response.data.result
})
.catch(function (error) {
self.loading = false;
});
},
注意vantjs的引入版本 必须在2.4.5以上才能生效