gpt4 book ai didi

javascript - 虚拟化 : Dependent v-select based on selection

转载 作者:行者123 更新时间:2023-12-02 21:45:13 25 4
gpt4 key购买 nike

我做了一个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com