小程序
小游戏
企业微信
微信支付
扫描小程序码分享
在使用switchTab方法跳转页面后,onShow方法有时候没有执行,不知道有没有人遇到过这种问题,如何解决?感谢
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
情景:当我登录之后进入“我的”页面,然后退出登录,清除数据,再跳转到“我的”页面,重复再执行一次发现最后一次跳转到“我的”页面没有执行onshow()方法。
//设置页
logout:
function
(){
//退出登录
var
url =
'********'
request.request(url,{},
(res){
console.log(res.data)
try
{
wx.removeStorageSync(
'uinfo'
)
}
catch
(e) {
// Do something when catch error
console.log(
'remove storage fail'
wx.switchTab({
url:
'../mine/mine'
,
success:
// success
},
fail:
() {
// fail
complete:
// complete
})
'get'
//我的 页面
onShow:
this
.reload();
reload:
uinfo = wx.getStorageSync(
console.log(uinfo)
if
(uinfo){
(!uinfo.meta.userInfo.headImage)
headImg =
'../../image/headimg@2x.png'
;
else
headImg = uinfo.meta.userInfo.headImage;
.setData({
headImg:headImg,
nickName:uinfo.meta.userInfo.nickName,
token:uinfo.meta.token,
emptyPageType:
''
.collect();
emptyPagaType:
'product'
headImg:
token:
nickName:
brandList:[],
productList:[]
我在onShow方法中打印的东西在第二次的时候没有出现。不确定这个问题是我自己的问题还是什么问题,感谢
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
提供一下复现方法以及关键代码,目前没有复现上述问题
最好按照置顶中的提问格式提问,方便开发人员定位问题
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
情景:当我登录之后进入“我的”页面,然后退出登录,清除数据,再跳转到“我的”页面,重复再执行一次发现最后一次跳转到“我的”页面没有执行onshow()方法。
//设置页
logout:
function
(){
//退出登录
var
url =
'********'
request.request(url,{},
function
(res){
console.log(res.data)
try
{
wx.removeStorageSync(
'uinfo'
)
}
catch
(e) {
// Do something when catch error
console.log(
'remove storage fail'
)
}
wx.switchTab({
url:
'../mine/mine'
,
success:
function
(res){
// success
},
fail:
function
() {
// fail
},
complete:
function
() {
// complete
}
})
},
'get'
)
}
//我的 页面
onShow:
function
(){
this
.reload();
}
reload:
function
(){
var
uinfo = wx.getStorageSync(
'uinfo'
)
console.log(uinfo)
if
(uinfo){
if
(!uinfo.meta.userInfo.headImage)
var
headImg =
'../../image/headimg@2x.png'
;
else
var
headImg = uinfo.meta.userInfo.headImage;
this
.setData({
headImg:headImg,
nickName:uinfo.meta.userInfo.nickName,
token:uinfo.meta.token,
emptyPageType:
''
})
this
.collect();
}
else
{
this
.setData({
emptyPagaType:
'product'
,
headImg:
'../../image/headimg@2x.png'
,
token:
''
,
nickName:
''
,
brandList:[],
productList:[]
})
}
},
我在onShow方法中打印的东西在第二次的时候没有出现。不确定这个问题是我自己的问题还是什么问题,感谢
提供一下复现方法以及关键代码,目前没有复现上述问题
最好按照置顶中的提问格式提问,方便开发人员定位问题