代碼地址以下:
http://www.demodashi.com/demo/14009.htmlhtml
軟件環境:微信開發者工具
官方下載地址:https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/download.html小程序
a.導航滾動微信小程序
<!--pages/scrollnav/scrollnav.wxml--> <!--導航滾動 --> <scroll-view class="tui-city-scroll" scroll-x="true" scroll-into-view="NAV{{status}}" scroll-with-animation="true"> <text bindtap="getStatus" id="NAV{{index}}" class="tui-nav-li {{index === status ? 'tui-nav-active' : ''}}" data-index="{{index}}" wx:for="{{navList}}" wx:key="">{{item}}</text> </scroll-view>
b.列表滾動區微信
<!--列表滾動區 --> <view class="tui-fixed-y"> <scroll-view class="tui-city-scroll-y" scroll-y="true" scroll-into-view="NAV{{status}}" scroll-with-animation="true"> <view wx:for="{{navList}}" wx:key=""> <view id="NAV{{index}}" class="tui-list-head">{{item}}</view> <view class="tui-list-li">{{item}} 列表 {{index}}</view> </view> </scroll-view> </view>
/* pages/scrollnav/scrollnav.wxss */ .tui-fixed-x{ width: 100%; position: fixed; top: 0; left: 0; } .tui-city-scroll{ height: 220rpx; line-height: 80rpx; width: 100%; white-space: nowrap; } .tui-city-scroll text{ height: 120rpx; line-height: 80rpx; width: 100%; white-space: nowrap; } .tui-nav-li{ font-size: 33rpx; padding: 0 10rpx; } .tui-nav-li:first-child{padding-left: 16rpx;} .tui-nav-li:last-child{padding-right: 16rpx;} .tui-nav-active{ color: red; border-bottom: 3rpx solid red; } .tui-fixed-y{ width: 100%; height: calc(100% - 80rpx); position: fixed; bottom: 0; left: 0; } .tui-city-scroll-y{ padding: 0 20rpx; height: 100%; box-sizing: border-box; } .tui-list-head{ height: 50px; line-height: 50px; text-align: center; font-size: 30rpx; color: blue; } .tui-list-li{ height: 400px; padding: 10rpx; color: #fff; font-size: 50rpx; background-color: #2EB3FF; }
a.錨點切換部分的功能實現微信開發
getStatus(e){ this.setData({ status: e.currentTarget.dataset.index}) }
暫時沒微信小程序基於scroll-view實現錨點定位xss
注:本文著做權歸做者,由demo大師代發,拒絕轉載,轉載須要做者受權ui