wxml:
<!--index.wxml-->
<view class="container">
<!--品牌-->
<scroll-view scroll-y="true" scroll-into-view="{{toView}}">
<view wx:for="{{citysMap}}">
<view class="ncq-smal" id="{{index}}">
{{index}}
</view>
<view wx:for="{{item}}" wx:for-item="citys" class="ncq-box"
data-cityname="{{citys.city_name}}" bindtap="cityNameClick">
<label class="ncq-brand-name">{{citys.city_name}}</label>
</view>
</view>
</scroll-view>
<!-- 字母导航-->
<view class="ncq-fixe-nav">
<view wx:for="{{citysMap}}" data-letter="{{index}}" bindtap="rightZmClick">
<label>{{index}}</label>
</view>
</view>
<!-- 字母导航end-->
</view>
js:
//字母锚链定位
topZmClick: function (event) {
var letter = event.currentTarget.dataset.letter;
this.setData({
toView: letter
})
},
wxss:
scroll-view {
height: 600px;
}
注:scroll-view必须要设置高度,不然无效