基础库版本:3.0.1
代码片段:https://developers.weixin.qq.com/s/fcd0vcmr7DLP
project.config.json里的appid需要替换成自己的
点击页面“手机号授权”按钮就报“ this.resolvePrivacyAuthorization is not a function”?
wxml:
<button open-type="getPhoneNumber|agreePrivacyAuthorization" bindgetphonenumber="Brushfacelogin" bindagreeprivacyauthorization="handleAgreePrivacyAuthorization" >手机号授权</button>
js:
Page({
data:{
},
onLoad() {
wx.onNeedPrivacyAuthorization((resolve, eventInfo) => {
console.log('触发本次事件的接口是:' + eventInfo.referrer)
this.resolvePrivacyAuthorization = resolve
})
},
handleAgreePrivacyAuthorization() {
console.log(2)
this.resolvePrivacyAuthorization({ buttonId: 'agree-btn', event: 'agree' })
},
Brushfacelogin (e) {
console.log(1)
}
})
兄弟,你的js里并没有定义这个resolvePrivacyAuthorization方法,当然报错啦
这个不是已经定义了吗?
遇到这种有可能为 null 的东西,多做点判空,也多画一下流程图,前置步骤有问题,后面在努力也白费