微信小程序实现楼层锚点跳跃,点击不同的锚点进行位置跳跃:
利用:scroll-into-view 来实现
效果图如下:
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">自动定位</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({ /** * 页面的初始数据 */ 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: "东北地区", 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: "华北地区", 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: "华东地区", city: [{ id: "0303", name: "开封市" }, { id: "3104", name: "安阳市" },] }, { id: "04", region: "华南地区", 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: "华中地区", city: [{ id: "0501", name: "黑龙江市" }] }, { id: "06", region: "西北地区", city: [{ id: "0603", name: "开封市" }, { id: "0604", name: "安阳市" },] }, { id: "07", region: "西南地区", 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) { } })
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
P70系列延期,华为新旗舰将在下月发布
3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。
而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?
根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。
更新日志
2024年11月14日
2024年11月14日
- 魔兽世界wlk暗牧一键输出宏是什么 wlk暗牧一键输出宏介绍
- 群星.1996-红不让台语原唱2辑【福和唱片】【WAV+CUE】
- 郭书瑶.2009-爱的抱抱(EP)【种子音乐】【FLAC分轨】
- 郑瑞芬.1989-BE.MY.BABY【现代】【WAV+CUE】
- 花钱请人每周放30万只不咬人的蚊子 防治登革热传播
- 饭制《第一后裔》丧尸版弗蕾娜
- 贝克汉姆亲临!2024FC品类游戏嘉年华圆满落幕
- 「命轨爻错之翼」风之翼发放说明
- 《原神》前瞻特别节目回顾长图
- 米游币抽抽乐-原神专场现已开启!
- 黑鸭子2001《风情中国HQCD》[日本版][WAV+CUE]
- 陈杰洲1990-成人礼[滚石][WAV+CUE]
- MarkAanderud-HandsFree(2024)[24-44,1]FLAC
- 孙露《观心》1:1母盘直刻限量版[低速原抓WAV+CUE][361M]
- 钟志刚《汽车DJ玩主》[低速原抓WAV+CUE][1G]