要求根据首字母展示城市;
循环首字母:
<span class="querycaption">按省份首字母选择:</span>
<el-radio-group class="selectone" v-model="radioSelectone" >
<el-radio-button v-for="(item,index) of letterList" :key="index" :label="item" @click.native="captionChange(item)"></el-radio-button>
</el-radio-group>
循环城市 :
<div class="container list" style="background-color: #f4f6f9; padding: 20px 2px;" >
<div class="subcontainer">
<div v-for="(item,index) of citylist" :key="index" >
<h3 class="cities-show__text" :id="'alphabet_'+item.alphabet">{{item.alphabet}}</h3>
<el-button v-for="(list,j) of item.cityList" :key="j" @click.native="radioChange(list.cityCode,list.cityName)" style="width: 180px; height: 60px;margin-top: 20px;margin-right: 10px; margin-left: 0px;">{{list.cityName}}</el-button>
</div>
</div>
</div>
点击首字母定位页面位置:
captionChange(caption){
document.getElementById("alphabet_"+caption).scrollIntoView()
},
根据id定位页面位置;