关于getUserInfo button提示请升级微信版本
发布于 6 年前 作者 alu 2872 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)
  • 预期表现
  • 复现路径
  • 提供一个最简复现 Demo

xml中:

<button class= 'btn-area’wx:if="{{canIUse}}" open-type=“getUserInfo”  bindgetuserinfo=“bindGetUserInfo”>

登录</button>

<button class= 'btn-area’wx:else open-type=“getUserInfo”  type=“warn”  disabled=“true” bindgetuserinfo=“bindGetUserInfo”>请升级微信版本</button>

js中:

data: {

motto: ‘Hello World’,

userInfo: {},

hasUserInfo: false,

canIUse: wx.canIUse(“button.open-type.getUserInfo”)

},

发现做的好傻啊,我如果把上面代码作为启动界面,就可以正常,如果是直接进入程序,没有用户信息,再调用获取用户信息的界面就会这样,提示                          请升级微信版本!!! 但是我的微信是最新的!!!


按照下面大神的把 can use去掉了 但是又多了一个问题

VM22668:1 Do not have bindGetUserInfo handler in current page

但是我的事件已经写了并且绑定了啊


bindGetUserInfo: function (e) {////第一次登录未授权

console.log(“bindGetUserInfo”)

if (e.detail.errMsg.indexOf(“deny”) > -1) {

wx.showToast({

title: ‘为保证全方位服务,请授权登录’,

icon: ‘none’,

})

} else if (app.globalData.isConnected) {

app.saveUserInfo();

wx.switchTab({

url: “…/…/pages/shoppingcart/shoppingcart”  // 页面 A

})

} else {

wx.showToast({

title: ‘当前无网络’,

icon: ‘none’,

})

}

}

})




3 回复

太低版本根本没必要支持,技术应该倒逼用户升级

https://developers.weixin.qq.com/miniprogram/dev/framework/client-lib/version.html

看看占比,这个canIUse根本没必要设置了,1.3以下仅仅是0.02%

而且模拟器无法跳转,只有在debug情况下才能跳转

手机可以正常跳转

回到顶部