<u-index-list :index-list="indexList" :scroll-top="scrollTop">
<view v-for="(item, index) in indexList" :key="index">
<u-index-anchor :index="item" />
<view v-for="(c,i) in filterCity(item)" :key="i" class="list-cell" @tap="selectCity(c.city)">
{{ c.city }}
</view>
</view>
</u-index-list>
filterCity(pinyin) {
//过滤 只剩与当前首字母(item)匹配的项
return this.cityPinyinList.filter(item => item.pinyin.substring(0, 1) === pinyin)
}
数据不带拼音的话 可以使用下面这个插件
npm install js-pinyin -S
import pinyin from ‘js-pinyin’