码迷,mamicode.com
首页 > 微信 > 详细

微信小程序之用户信息授权 wx.getUserInfo

时间:2018-11-22 18:12:49      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:pen   微信小程序   ons   open   pre   success   data   his   按钮   

用户授权

<button open-type="getUserInfo" bindgetuserinfo='getUser'>授权用户信息</button>
getUser(e) {
    console.log(e);
    wx.getUserInfo({
        success: (res) => {
            console.log(res)
            this.setData({
                userInfo: res.userInfo
            });
        }
    })
}
  • 点击上面 button 后弹出授权窗口;
  • 如果用户同意授权,将获取到用户信息,再次点击button后不会弹窗。
  • 如果用户拒绝授权,不会获取到用户信息,再次点击按钮,会再次弹出授权窗口。

微信小程序之用户信息授权 wx.getUserInfo

标签:pen   微信小程序   ons   open   pre   success   data   his   按钮   

原文地址:https://www.cnblogs.com/cckui/p/10002430.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!