1 设置位置
....
pageData:{
locationObj:{}
},
........
//获取位置
//Cannot read property 'pageData' of undefined;at api chooseLocation success callback function 有可能是在回调函数内使用this
chooseLocation:function(e){
wx.chooseLocation({
success:res=> {
let locationObj = {
latitude:res.latitude,
longitude: res.longitude,
name: res.name,
address:res.address
}
this.pageData.locationObj = locationObj
},
})
}
<van-cell
wx:if="{{task.location}}"
title="位置"
border="{{false}}"
value="{{task.location.name}}"/>
网友评论