mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-10-05 00:09:58 +08:00
[bugfix] Area: should not display city & county list when not select province (#560)
This commit is contained in:
parent
91872a3101
commit
e7720506ba
@ -94,23 +94,23 @@ export default create({
|
|||||||
|
|
||||||
// 根据省市县类型和对应的`code`获取对应列表
|
// 根据省市县类型和对应的`code`获取对应列表
|
||||||
getList(type, code) {
|
getList(type, code) {
|
||||||
if (!this.listValid) {
|
let result = [];
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
const { areaList } = this;
|
if (this.listValid && (type === 'province' || code)) {
|
||||||
const list =
|
const { areaList } = this;
|
||||||
type === 'province'
|
const list =
|
||||||
? areaList.province_list
|
type === 'province'
|
||||||
: type === 'city' ? areaList.city_list : areaList.county_list;
|
? areaList.province_list
|
||||||
|
: type === 'city' ? areaList.city_list : areaList.county_list;
|
||||||
|
|
||||||
let result = Object.keys(list).map(code => ({
|
result = Object.keys(list).map(code => ({
|
||||||
code,
|
code,
|
||||||
name: list[code]
|
name: list[code]
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (type !== 'province' && code) {
|
if (type !== 'province' && code) {
|
||||||
result = result.filter(item => item.code.indexOf(code) === 0);
|
result = result.filter(item => item.code.indexOf(code) === 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result.unshift({
|
result.unshift({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user