显示省份简称,如内蒙古自治区:内蒙古
需要實(shí)現(xiàn)的效果圖:
1、過(guò)濾不需要顯示的省份
this.filterArea('臺(tái)灣省')
this.filterArea('香港特別行政區(qū)')
this.filterArea('澳門(mén)特別行政區(qū)')
// 過(guò)濾不需要顯示的省份
? ? filterArea(val) {
? ? ? this.cities.splice(this.cities.findIndex(item => item.label === val), 1)
},
2、需要對(duì)省份進(jìn)行截取,不需要顯示全稱(chēng)。只顯示簡(jiǎn)稱(chēng),可以使用以下方法。
<el-checkbox-group v-model="tradeRangeIds"><el-checkbox v-for="item in cities" :label="item.value" :key="item.value">{{ showProvince(item.label) }}</el-checkbox> </el-checkbox-group>showProvince(name) {
? ? ? // 顯示省份簡(jiǎn)稱(chēng)
? ? ? // 省 市 自治區(qū) 特別行政區(qū) 維吾爾 壯族 回族
? ? ? try {
? ? ???? name = name.replace('省', '').replace('市', '').replace('自治區(qū)', '').replace('特別行政區(qū)', '').replace('維吾爾', '')
? ? ? ? name = name.replace('壯族', '').replace('回族', '')
? ? ? } catch (error) {
? ? ? ? console.error('showProvince:', name)
? ? ? }
? ? ? return name
? ? },
?
?所有省份數(shù)據(jù)。
this.cities = [
??? {
??????? "label": "北京市",
??????? "value": "32"
??? },
??? {
??????? "label": "天津市",
??????? "value": "33"
??? },
??? {
??????? "label": "河北省",
??????? "value": "24"
??? },
??? {
??????? "label": "山西省",
??????? "value": "26"
??? },
??? {
??????? "label": "內(nèi)蒙古自治區(qū)",
??????? "value": "3"
??? },
??? {
??????? "label": "遼寧省",
??????? "value": "7"
??? },
??? {
??????? "label": "吉林省",
??????? "value": "34"
??? },
??? {
??????? "label": "黑龍江省",
??????? "value": "4"
??? },
??? {
??????? "label": "上海市",
??????? "value": "10"
??? },
??? {
??????? "label": "江蘇省",
??????? "value": "18"
??? },
??? {
??????? "label": "浙江省",
??????? "value": "23"
??? },
??? {
??????? "label": "安徽省",
??????? "value": "14"
??? },
??? {
??????? "label": "福建省",
??????? "value": "15"
??? },
??? {
??????? "label": "江西省",
??????? "value": "22"
??? },
??? {
??????? "label": "山東省",
??????? "value": "8"
??? },
??? {
??????? "label": "河南省",
??????? "value": "2"
??? },
??? {
??????? "label": "湖北省",
??????? "value": "6"
??? },
??? {
??????? "label": "湖南省",
??????? "value": "16"
??? },
??? {
??????? "label": "廣東省",
??????? "value": "1"
??? },
??? {
??????? "label": "廣西壯族自治區(qū)",
??????? "value": "20"
??? },
??? {
??????? "label": "海南省",
??????? "value": "17"
??? },
??? {
??????? "label": "重慶市",
??????? "value": "12"
??? },
??? {
??????? "label": "四川省",
??????? "value": "30"
??? },
??? {
??????? "label": "貴州省",
??????? "value": "11"
??? },
??? {
??????? "label": "云南省",
??????? "value": "31"
??? },
??? {
??????? "label": "西藏自治區(qū)",
??????? "value": "13"
??? },
??? {
??????? "label": "陜西省",
??????? "value": "9"
??? },
??? {
??????? "label": "甘肅省",
??????? "value": "29"
??? },
??? {
??????? "label": "青海省",
??????? "value": "19"
??? },
??? {
??????? "label": "寧夏回族自治區(qū)",
??????? "value": "21"
??? },
??? {
??????? "label": "新疆維吾爾自治區(qū)",
??????? "value": "5"
??? },
??? {
??????? "label": "臺(tái)灣省",
??????? "value": "27"
??? },
??? {
??????? "label": "香港特別行政區(qū)",
??????? "value": "25"
??? },
??? {
??????? "label": "澳門(mén)特別行政區(qū)",
??????? "value": "28"
??? }
]
總結(jié)
以上是生活随笔為你收集整理的显示省份简称,如内蒙古自治区:内蒙古的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: php循环输出数组 json,php循环
- 下一篇: Kilobots模拟器Kilombo