From e7720506ba333434afa23574345d09f9fadee559 Mon Sep 17 00:00:00 2001 From: neverland <chenjiahan@buaa.edu.cn> Date: Mon, 22 Jan 2018 16:20:16 +0800 Subject: [PATCH] [bugfix] Area: should not display city & county list when not select province (#560) --- packages/area/index.vue | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/area/index.vue b/packages/area/index.vue index b01e9cf6f..1a3e3f7ac 100644 --- a/packages/area/index.vue +++ b/packages/area/index.vue @@ -94,23 +94,23 @@ export default create({ // 根据省市县类型和对应的`code`获取对应列表 getList(type, code) { - if (!this.listValid) { - return []; - } + let result = []; - const { areaList } = this; - const list = - type === 'province' - ? areaList.province_list - : type === 'city' ? areaList.city_list : areaList.county_list; + if (this.listValid && (type === 'province' || code)) { + const { areaList } = this; + const list = + type === 'province' + ? areaList.province_list + : type === 'city' ? areaList.city_list : areaList.county_list; - let result = Object.keys(list).map(code => ({ - code, - name: list[code] - })); + result = Object.keys(list).map(code => ({ + code, + name: list[code] + })); - if (type !== 'province' && code) { - result = result.filter(item => item.code.indexOf(code) === 0); + if (type !== 'province' && code) { + result = result.filter(item => item.code.indexOf(code) === 0); + } } result.unshift({