小程序静默授权获取unionid

在这里插入图片描述

文章目录


导文

小程序静默授权获取unionid

文章重点

用wx.login(Object object)放到app.js里面

 wx.login({
      success (res) {
        console.log(123);
        if (res.code) {
          //发起网络请求
          // wx.request({
          //   url: 'https://example.com/onLogin',
          //   data: {
          //     code: res.code
          //   }
          // })
          console.log(res.code,'res.code');
        } else {
          console.log('登录失败!' + res.errMsg)
        }
      }
    })

效果:
在这里插入图片描述

您好,我是肥晨。
欢迎关注我获取前端学习资源,日常分享技术变革,生存法则;行业内幕,洞察先机。

猜你喜欢

转载自blog.csdn.net/weixin_48998573/article/details/134667787