提交 f0241a2d 编写于 作者: KK's avatar KK

优化组件

上级 b8cba27f
<template> <template>
<div class="appAddressSelection"> <div class="appAddressSelection">
<el-cascader <el-cascader
style="width:100%"
:disabled="disabled" :disabled="disabled"
size ="medium" size ="medium"
v-model="CurrentVal" v-model="CurrentVal"
...@@ -14,6 +15,7 @@ import { Component, Vue, Prop, Model, Watch } from 'vue-property-decorator'; ...@@ -14,6 +15,7 @@ import { Component, Vue, Prop, Model, Watch } from 'vue-property-decorator';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
import axios from 'axios'; import axios from 'axios';
import { cityCode } from './city_code'
@Component({}) @Component({})
export default class AppAddressSelection extends Vue { export default class AppAddressSelection extends Vue {
...@@ -63,12 +65,7 @@ export default class AppAddressSelection extends Vue { ...@@ -63,12 +65,7 @@ export default class AppAddressSelection extends Vue {
* @memberof AppAddressSelection * @memberof AppAddressSelection
*/ */
public getcity() { public getcity() {
axios.get("../../assets/json/city_code.json").then((response: any) => { this.format(cityCode);
this.format(response.data);
}).catch((response: any) => {
console.log((this.$t('components.appAddressSelection.loadDataFail') as string));
});
} }
/** /**
...@@ -86,11 +83,11 @@ export default class AppAddressSelection extends Vue { ...@@ -86,11 +83,11 @@ export default class AppAddressSelection extends Vue {
* @memberof AppAddressSelection * @memberof AppAddressSelection
*/ */
public format(data :any) { public format(data :any) {
let data1 = JSON.parse(JSON.stringify(data).replace(/city/g, 'children')) let town = JSON.parse(JSON.stringify(data).replace(/city/g, 'children'))
let data2 = JSON.parse(JSON.stringify(data1).replace(/name/g, 'label')) let county = JSON.parse(JSON.stringify(town).replace(/name/g, 'label'))
let data3 = JSON.parse(JSON.stringify(data2).replace(/area/g, 'children')) let city = JSON.parse(JSON.stringify(county).replace(/area/g, 'children'))
let data4 = JSON.parse(JSON.stringify(data3).replace(/code/g, 'value')) let province = JSON.parse(JSON.stringify(city).replace(/code/g, 'value'))
this.city = data4; this.city = province;
} }
} }
......
此差异已折叠。
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册