官方提供了新的获取用户信息的方案,非要用"getUserProfile"?改一改代码,使用新方案,不香么?
使用uniapp开发小程序获取用户信息按钮需要点击两次才能获得到用户信息?用uniapp开发小程序,开发者工具本地测试没有问题,但是真机测试的时候获取用户信息那里不知道为何要点两次才能成功,第一次会提示错误 getUserProfile:fail can only be invoked by user TAP gesture 第二次才会成功,底下是我的代码 <button v-if="but" class='bottom' type='primary' @click="goLogin"> 获取用户信息 </button> getUserProfile() { // 判断缓存中是否有用户数据,没有则获取 uni.getUserProfile({ desc: '獲取您的昵稱、頭像、地區及性別', success: infoRes => { console.log('登陆成功', infoRes) if (infoRes.errMsg === 'getUserProfile:ok') { uni.showToast({ title: '授權成功', icon: 'success' }); } else { uni.showToast({ title: '授權失敗', icon: 'error' }); } }, fail: err => { console.log('userInfo-err', JSON.stringify(err)); } }); }, 我尝试过使用 <button v-if="but" class='bottom' type='primary' open-type="getUserProfile" bindtap="getUserProfile" > 获取用户信息 </button> 但是又会出现另外一个错误 "pages/login/login" does not have a method "getUserProfile" to handle event "tap"
2023-07-06我这边请求错位。 模拟器存在问题,真机无问题。 如图1,请求的是 “car/list”,success回调log显示的data,却是另外一个接口的数据。 如图2,“car/list” 接口的请求response [图片] [图片]
pc端调试http请求报错?开发者工具版本1.06.2303220,调式工具微信版本3.9.2,基础库版本2.26.1,使用pc调试工具,调用wx.request接口后在network中看到请求成功,但是在console中报错: Uncaught (in promise) TypeError: globalThis.RemoteDebugger.debuggerConnection.onReceiveNetworkHeader is not a function servicewechat.com/wx7a4d9c6d28f07e4e/0/index.js:3 但是用真机调试没有此问题
2023-05-27