问题:调用getCurrentPages()在安卓和iphone真机都出现报错,而在电脑模拟机上正常。
代码如下:
chooseAddress:function(e){
var addr_id = e.currentTarget.dataset.addr_id
var province = e.currentTarget.dataset.province
var city = e.currentTarget.dataset.city
var county = e.currentTarget.dataset.county
var addr = e.currentTarget.dataset.addr
console.log(‘addr_id=====’ + addr_id)
console.log(‘province=====’ + province)
console.log(‘city=====’ + city)
console.log(‘county=====’ + county)
console.log(‘addr=====’ + addr)
var new_address = province+city+county+addr
console.log(‘new_address=====’ + new_address)
var pages = getCurrentPages();//获取页面栈
console.log(pages)
var currpage = pages[pages.length - 1];//当前页面
var prevPage = pages[pages.length - 2]; //上一个页面(父页面)
console.log(‘prevPage========’, prevPage)
prevPage.setData({
province: province,
city: city,
county: county,
addr: addr,
addr_id: addr_id
})
wx.navigateBack({
url: ‘/pages/order/order-pay/order-pay’
})
return;
},
在真机上console.log(pages)就报错了,报错如上截图