- 当前 Bug 的表现(可附上截图)
navigateTo 失效
- 预期表现
判断登录成功直接跳转,不再显示登录页
- 复现路径
pages/login/login
login() {
const that = this
wx.showModal({
title: ‘提示’,
content: ‘这是一个模态弹窗’,
success(res) {
if (res.confirm) {
console.log(‘用户点击确定’),
wx.login({
success() {
app.globalData.hasLogin = true
that.setData({
hasLogin: true
})
}
})
wx.navigateTo({
url: ‘…/home/home’
})
} else if (res.cancel) {
console.log(‘用户点击取消’)
}
}
})
},
onShow() {
console.log(‘App Show’, app.globalData.hasLogin)
if (this.data.hasLogin) {
wx.navigateTo({
url: ‘…/home/home’
})
}
}
- 提供一个最简复现 Demo
<view class=‘login-container’>
<image class=“app-logo” src="…/…/images/登录_03.png" />
<block wx:if="{{hasLogin === true}}">
<navigator url=’…/my/my’ open-type=“redirect”>aa</navigator>
</block>
<block wx:if="{{hasLogin === false}}">
<button class=“wx-login-button” bindtap=“login”>微信用户一键登录</button>
<text class=“phone-login-text” bindtap=“phoneLogin”>手机号码登录</text>
</block>
</view>