分享你我的心得.
共乘一片美好网络.

wx.openLocation调取失败

解决方法:

微信小程序默认将组件上绑定的参数都当作字符串了,所以认为坐标点不正确,强制转换成number类型即可。

var lat = Number(e.currentTarget.dataset.lat),
lng = Number(e.currentTarget.dataset.lng),
name = e.currentTarget.dataset.name,
address = e.currentTarget.dataset.address;

wx.openLocation({
latitude: lat,
longitude: lng,
scale: 18,
name: name,
address: address,
success: function (res) {
console.log(res)
},
fail: function (res){
console.log(res)
}
})

赞(0)
未经允许不得转载:小叶白龙博客 » wx.openLocation调取失败
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址