微信小程序之用戶信息授權 wx.getUserInfo


用戶授權

<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后不會彈窗。
  • 如果用戶拒絕授權,不會獲取到用戶信息,再次點擊按鈕,會再次彈出授權窗口。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM