提交 fc324030 authored 作者: haodaking's avatar haodaking

chore: 省市数据按拼音排序

上级 de9196db
import { areaList } from '@vant/area-data'
// json to array
const json2Array = function (data: Record<string, string>) {
return Object.keys(data).map(code => ({ code, label: data[code], value: data[code] }))
......@@ -13,12 +12,21 @@ export function useArea() {
cityValue.value = ''
})
const provinceList = ref(json2Array(areaList.province_list))
const cityList = computed(() => {
return json2Array(areaList.city_list).filter(item => {
const provinceValueCode = provinceList.value.find(province => province.label === provinceValue.value)?.code || ''
return item.code.slice(0, 2) === provinceValueCode.slice(0, 2)
const provinceList = ref(
json2Array(areaList.province_list).sort((a, b) => {
return a.label.localeCompare(b.label)
})
)
const cityList = computed(() => {
return json2Array(areaList.city_list)
.filter(item => {
const provinceValueCode =
provinceList.value.find(province => province.label === provinceValue.value)?.code || ''
return item.code.slice(0, 2) === provinceValueCode.slice(0, 2)
})
.sort((a, b) => {
return a.label.localeCompare(b.label)
})
})
const treeList = json2Array(areaList.province_list).map(item => {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论