微信小程序 getUserProfile直接进入fail函数,getUserProfile调用失败:fail can only be invoked by user TAP gesture.
2022/7/3 1:24:32
本文主要是介绍微信小程序 getUserProfile直接进入fail函数,getUserProfile调用失败:fail can only be invoked by user TAP gesture.,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
问题描述
小程序更改了调用用户信息的接口,详情
调用getUserProfile直接进入失败
返回的错误信息如下
getUserProfile:fail can only be invoked by user TAP gesture.
大概意思是此接口只能通过用户点击调用
修改
我们稍作调整,使用按钮进行调用
wx.showModal({ title: '温馨提示', content: '亲,授权微信登录后才能正常使用小程序功能', success(res) { console.log(0) console.log(res) //如果用户点击了确定按钮 if (res.confirm) { wx.getUserProfile({ desc: '获取你的昵称、头像、地区及性别', success: res => { console.log(res); console.log(1); }, fail: res => { console.log(2); console.log(res) //拒绝授权 wx.showToast({ title: '您拒绝了请求,不能正常使用小程序', icon: 'error', duration: 2000 }); return; } }); } else if (res.cancel) { //如果用户点击了取消按钮 console.log(3); wx.showToast({ title: '您拒绝了请求,不能正常使用小程序', icon: 'error', duration: 2000 }); return; } } });
如果你还报错,getUserProfile调用失败:fail desc length does not meet the requirements,请看我另外一篇文章
微信小程序 getUserProfile直接进入fail函数,getUserProfile调用失败:fail desc length does not meet the requirements
————————————————
版权声明:本文为CSDN博主「Gabriel_wei」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/Gabriel_wei/article/details/115607347
这篇关于微信小程序 getUserProfile直接进入fail函数,getUserProfile调用失败:fail can only be invoked by user TAP gesture.的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-30微信小程序的网络设置,及网络请求:wx.request(OBJECT)
- 2024-01-22基于taro搭建小程序多项目框架
- 2024-01-13小程序开发:在插件市场寻找步骤条组件并二开
- 2024-01-05钉钉小程序生态—企业机器人加互动卡片,改善用户体验的开始!
- 2023-12-29【UniApp】-uni-app-打包成小程序
- 2023-12-26性能翻倍!京东亿级体量小程序优化实践
- 2023-12-25小程序优化:第三方SDK过大解决方案
- 2023-11-26微信小程序文件预览和下载-文件系统
- 2023-11-2652天学习微信小程序计划No.2:注册小程序账号&安装开发者工具
- 2023-11-1952天学习微信小程序计划No.1:小程序简介