var template = '' $.ajax('../../../component/statistics/LascModifyPatient/index.html', { data: {}, dataType: 'html', cache: false, timeout: 60000, async: false, error: function (res) {}, success: function (res) { template = res } }) Vue.component('lasc-modify-patient', { template: template, props: [], data: function () { return { form: {}, menophaniaAgeList: [], selAddress: '350200', // 默认值 selectedStreet: '', areaList: areaDataArr, areaOptions: [], // 地区数据 rules: {}, cascaderProps: { value: 'value', label: 'label', children: 'children', expandTrigger: 'hover', checkStrictly: true, // 可以只选父级 emitPath: false // 只返回最后一级的值 } } }, methods: { handleItemChange(item, type) {}, loadAreaData() { this.areaOptions = Object.keys(this.areaList.province_list).map(provinceCode => ({ value: provinceCode, label: this.areaList.province_list[provinceCode], children: this.getCityChildren(provinceCode) })) }, // 获取城市子节点 getCityChildren(provinceCode) { const prefix = provinceCode.substring(0, 2) return Object.keys(this.areaList.city_list) .filter(cityCode => cityCode.startsWith(prefix)) .map(cityCode => ({ value: cityCode, label: this.areaList.city_list[cityCode] })) } }, mounted() { for (var i = 8; i < 21; i++) { this.menophaniaAgeList.push(i) } // 初始化时加载地区数据 this.loadAreaData() } })