先看一下wxml的代碼,綁定個事件! 然後是js的代碼,調用wx.chooseLocation方法 ...
先看一下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 } }) },