注意:a-cascader 的默认值显示数组的添加顺序一定要是从0到1这样的,要不然虽选中了但input不会显示
比如在我们对选中id数组初始化的时候,用push一定要注意添加的顺序,一级id一定是最先添加的,然后是二级id,三级id这样…
直接上代码片段
async getNewWebsiteInfo() {
this.$nuxt.$loading.start();
await getWebsite(window.$nuxt)
.then(res => {
if (res.code === 200) {
const data = res.data;
this.addressControl.city = data.city_name;
this.addressControl.postcode = data.city_post;
this.zoneData.forEach(item => {
if (item.countries && item.countries.length) {
item.countries.forEach(country => {
if (country.country_name === data.country_name) {
this.areaArray.push(country.zone_id);
this.areaArray.push(country.country_id);
if (country.states && country.states.length) {
country.states.forEach(state => {
if (state.state_name === data.region_name) {
this.areaArray.push(state.state_id);
}
});
}
}
});
}
});
}
})
.finally(res => {
this.$nuxt.$loading.finish();
});
},