如何获取微信当前用户的信息:通过open-type,具体需要什么可以通过微信开发工具调试器去查看。
wxml
<!--获取用户信息-->
<button size="mini" open-type="getUserInfo" bindgetuserinfo="handleGetUserInfo">
</button>
js
handleGetUserInfo:function(event){
console.log(event);
}
以下是原公告:
为优化用户体验,使用 wx.getUserInfo 接口直接弹出授权框的开发方式将逐步不再支持。从2018年4月30日开始,小程序与小游戏的体验版、开发版调用 wx.getUserInfo 接口,将无法弹出授权询问框,默认调用失败。正式版暂不受影响。
这里 open-type=“getUserInfo” 就这样写不要乱改。
1、使用 button 组件,并将 open-type 指定为 getUserInfo 类型,获取用户基本信息。
详情参考文档:https://developers.weixin.qq.com/miniprogram/dev/component/button.html
2、使用 open-data 展示用户基本信息。
详情参考文档:https://developers.weixin.qq.com/miniprogram/dev/component/open-data.html