微信小程序

1、滚动条使用官方推荐的组件scroll-view,示例如下:

 <scroll-view class="subway-map-box" scroll-x="true" enable-flex scroll-left="{{scrollLeft}}"> </scroll-view>
设置滚动条默认位置:
const index = list.findIndex(item => item== currentOperationType) that.setData({ scrollLeft: 宽度 * index })

2、获取用户定位

 1 var QQMapWX = require("../api/qqmap-wx-jssdk");//百度去找这个文件或者去官网
 2 var qqmapsdk = new QQMapWX({
 3       key: "",//官网开通定位权限,会生成一个唯一得key
 4     });
 5 setPosition(qqmapsdk, item, failContent) {
 6       const that = this
 7       qqmapsdk.reverseGeocoder({
 8         type: 'gcj02',
 9         success: (res) => {
10           const address = res.result.formatted_addresses.standard_address
11           const location = res.result.location
12         },
13         fail: (err) => {
14           //用户已授权,但是获取地理位置失败,会弹框提示用户去系统设置中打开定位
15           wx.showModal({
16             title: '',
17             content: failContent,
18             confirmText: '确定',
19             success: function (res) {
20             }
21           })
22         }
23       })
24     }

3、自定义两个组件:

 

  

 

posted on 2023-11-06 17:51  ihuangqing  阅读(30)  评论(0编辑  收藏  举报