我做了一个 codepent - 示例: https://codepen.io/rasenkantenstein/pen/qBdZepM
用户应该选择一个国家,并最终只选择属于该国家的城市。然而,人的数据背后却有一个数组。我如何告诉 Vue(tify) 仅更改当前编辑行中的那些项目?
changeCity(index, country) {
//How can I filter the cities here for each person?
let result = this.cities.filter(city => {
return city.country == country
})
console.log(result)
//this works on all fields... ? --> this.cities = result
}
最佳答案
您应该在 v-select 中根据所在国家/地区过滤城市,如下所示:
:items="cities.filter(c => c.country === person.country)"
关于javascript - 虚拟化 : Dependent v-select based on selection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60268823/