1. 程式人生 > >微信小程序調用地圖選取位置後返回信息

微信小程序調用地圖選取位置後返回信息

name arp ble com 代碼 this inpu pre ESS

先看一下wxml的代碼,綁定個事件!

<view class=‘carpool_data_all‘>

<view class=‘aa‘>

<text>*出發地</text>

</view>

<view class=‘bb‘ bindtap=‘selectlocation‘>

<input disabled placeholder=‘請選擇出發地‘ value="{{departure}}"></input>

</view>

</view>

  然後是js的代碼,調用wx.chooseLocation方法

selectlocation:function(){
var that = this
wx.chooseLocation({
success: function (res) {
// success
console.log(res.name)
that.setData({
departure: res.name,
})
},
fail: function () {
// fail
},
complete: function () {
// complete
}
})
},

  

微信小程序調用地圖選取位置後返回信息