render-district.vue
619 Bytes
<template>
<text class="render-district">{{ match.name || value }}</text>
</template>
<script>
import { mapGetters } from 'vuex';
export default {
name: 'RenderDistrict',
props: {
value: [String, Number],
type: String, // province,city,area
},
computed: {
...mapGetters(['districtValue']),
match({ value, type }) {
let code = value;
if (type === 'province') {
code = `${value}`.substring(0, 2) + '0000';
} else if (type === 'city') {
code = `${value}`.substring(0, 4) + '00';
}
return this.districtValue(code) || {};
}
},
};
</script>