微信小程序?qū)崿F(xiàn)錨點(diǎn)定位樓層跳躍的實(shí)例
更新時(shí)間:2017年05月18日 14:21:09 作者:Rolan
這篇文章主要介紹了微信小程序?qū)崿F(xiàn)錨點(diǎn)定位樓層跳躍的實(shí)例的相關(guān)資料,需要的朋友可以參考下
微信小程序?qū)崿F(xiàn)樓層錨點(diǎn)跳躍,點(diǎn)擊不同的錨點(diǎn)進(jìn)行位置跳躍:
利用:scroll-into-view 來實(shí)現(xiàn)
效果圖如下:
WXML:
<scroll-view class="content" scroll-into-view="{{toView}}" scroll-y="true" scroll-with-animation="true"> <view wx:for="{{act_addList}}"> <view class="address_top" id="{{ 'inToView'+item.id}}">{{item.region}}</view> <view wx:for="{{item.city}}"> <view class="address_bottom">{{item.name}}</view> </view> </view> </scroll-view> <view class="orientation_region"> <view class="orientation">自動(dòng)定位</view> <block wx:for="{{orientationList}}" > <view class="orientation_city" bindtap="scrollToViewFn" data-id="{{item.id}}">{{item.region}}</view> </block> </view>
WXSS:
page{ height: 100%;} .content{padding-bottom: 20rpx; box-sizing: border-box; height: 100%;} .location{width: 100%;} .location_top{height: 76rpx;line-height: 76rpx; background: #f4f4f4;color: #606660;font-size: 28rpx;padding: 0 20rpx;} .location_bottom{height: 140rpx;line-height: 140rpx;color: #d91f16;font-size: 28rpx;border-top: 2rpx #ebebeb solid; border-bottom: 2rpx #ebebeb solid;padding: 0 20rpx; align-items: center;display: -webkit-flex;} .address_top{height: 76rpx;line-height: 76rpx; background: #f4f4f4;color: #999999;font-size: 28rpx;padding: 0 20rpx;} .address_bottom{height: 88rpx;line-height: 88rpx; background: #fff;color: #000000;font-size: 32rpx;padding: 0 20rpx; border-bottom: 2rpx #ebebeb solid;margin-left: 20rpx;margin-right: 50rpx; } .location_img{width: 48rpx;height: 48rpx;position: absolute;right: 20rpx;top: 125rpx;} .add_city{width: 228rpx;height: 60rpx;line-height: 60rpx; text-align: center; border: 2rpx solid #ebebeb; color: #000000;margin-right: 20rpx; } .add_citying{width: 228rpx;height: 60rpx;line-height: 60rpx; text-align: center; border: 2rpx solid #09bb07; color: #09bb07;margin-right: 20rpx;} .orientation{white-space:normal;display: inline-block; width: 55rpx;height:58rpx; color: #999; text-align: center;} .orientation_region{ width: 55rpx;font-size: 20rpx;position: fixed;top: 220rpx; right: 0rpx;} .orientation_city{height: 50rpx; line-height: 50rpx;color: #000;text-align: center;}
JS:
Page({ /** * 頁面的初始數(shù)據(jù) */ data: { orientationList: [ { id: "01", region: "東北" }, { id: "02", region: "華北" }, { id: "03", region: "華東" }, { id: "04", region: "華南" }, { id: "05", region: "華中" }, { id: "06", region: "西北" }, { id: "07", region: "西南" } ], act_addList: [ { id: "01", region: "東北地區(qū)", city: [{ id: "0101", name: "白山江源" }, { id: "0102", name: "白山市" }, { id: "0103", name: "賓縣" }, { id: "0104", name: "大慶" }, { id: "0105", name: "測試1" }, { id: "0106", name: "測試2" }, { id: "0107", name: "測試3" }, { id: "0108", name: "測試4" }, { id: "0109", name: "測試5" }, { id: "0110", name: "測試6" }, ] }, { id: "02", region: "華北地區(qū)", city: [{ id: "0201", name: "包頭" }, { id: "0202", name: "保定" }, { id: "0206", name: "測試2" }, { id: "0207", name: "測試3" }, { id: "0208", name: "測試4" }, { id: "0209", name: "測試5" }, { id: "0210", name: "測試6" }, ] }, { id: "03", region: "華東地區(qū)", city: [{ id: "0303", name: "開封市" }, { id: "3104", name: "安陽市" },] }, { id: "04", region: "華南地區(qū)", city: [ { id: "0401", name: "黑龍江市" }, { id: "0407", name: "測試3" }, { id: "0508", name: "測試4" }, { id: "0609", name: "測試5" }, { id: "0710", name: "測試6" }, { id: "0711", name: "測試8" }, { id: "0712", name: "測試9" }, { id: "0713", name: "測試10" }, { id: "0714", name: "測試11" }, ] }, { id: "05", region: "華中地區(qū)", city: [{ id: "0501", name: "黑龍江市" }] }, { id: "06", region: "西北地區(qū)", city: [{ id: "0603", name: "開封市" }, { id: "0604", name: "安陽市" },] }, { id: "07", region: "西南地區(qū)", city: [{ id: "0703", name: "開封市" }, { id: "0704", name: "安陽市" }, { id: "0401", name: "黑龍江市" }, { id: "0407", name: "測試3" }, { id: "0508", name: "測試4" }, { id: "0609", name: "測試5" }, { id: "0710", name: "測試6" }, { id: "0711", name: "測試8" }, { id: "0712", name: "測試9" }, { id: "0713", name: "測試10" }, { id: "0714", name: "測試11" }, { id: "0401", name: "黑龍江市" }, { id: "0407", name: "測試3" }, { id: "0508", name: "測試4" }, { id: "0609", name: "測試5" }, { id: "0710", name: "測試6" }, { id: "0711", name: "測試8" }, { id: "0712", name: "測試9" }, { id: "0713", name: "測試10" }, { id: "0714", name: "測試11" }, ] }, ], toView: 'inToView01', }, scrollToViewFn: function (e) { var _id = e.target.dataset.id; this.setData({ toView: 'inToView' + _id }) console.log(this.data.toView) }, onLoad: function (options) { } })
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
您可能感興趣的文章:
- 微信小程序?qū)崿F(xiàn)錨點(diǎn)定位功能的方法實(shí)例
- 微信小程序?qū)崿F(xiàn)錨點(diǎn)跳轉(zhuǎn)
- 微信小程序scroll-view實(shí)現(xiàn)滾動(dòng)到錨點(diǎn)左側(cè)導(dǎo)航欄點(diǎn)餐功能(點(diǎn)擊種類,滾動(dòng)到錨點(diǎn))
- 微信小程序 scroll-view 實(shí)現(xiàn)錨點(diǎn)跳轉(zhuǎn)功能
- 微信小程序scroll-view錨點(diǎn)鏈接滾動(dòng)跳轉(zhuǎn)功能
- 微信小程序?qū)崿F(xiàn)錨點(diǎn)功能
- 小程序?qū)崿F(xiàn)錨點(diǎn)滑動(dòng)效果
- 微信小程序 scroll-view實(shí)現(xiàn)錨點(diǎn)滑動(dòng)的示例
- 微信小程序商城分類滾動(dòng)列表錨點(diǎn)的項(xiàng)目實(shí)踐
相關(guān)文章
微信小程序 圖片寬度自適應(yīng)的實(shí)現(xiàn)
這篇文章主要介紹了微信小程序 圖片寬度自適應(yīng)的實(shí)現(xiàn)的相關(guān)資料,需要的朋友可以參考下2017-04-04javascript進(jìn)階篇深拷貝實(shí)現(xiàn)的四種方式
這篇文章主要為大家介紹了javascript進(jìn)階篇深拷貝實(shí)現(xiàn)的四種方式詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-07-07JavaScript深拷貝方法structuredClone使用
這篇文章主要為大家介紹了JavaScript深拷貝方法structuredClone使用示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-02-02微信小程序上滑加載下拉刷新(onscrollLower)分批加載數(shù)據(jù)(二)
這篇文章主要介紹了微信小程序上滑加載下拉刷新(onscrollLower)分批加載數(shù)據(jù)的相關(guān)資料,需要的朋友可以參考下2017-05-05