小程序授权登录?
先建一个demo文件,在demo.wxml写
<!-- 需要使用 button 来授权登录 -->
<button wx:if="{
{canIUse}}" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo">授权登录</button>
<view wx:else>请升级微信版本</view>
在demo.js中写
Page({
data: {
canIUse: wx.canIUse('button.open-type.getUserInfo')
},
onLoad: function () {
// 查看是否授权
wx.getSetting({
success(res) {
if (res.authSetting['scope.userInfo'])