在inde.wxml文件中添加一个按钮,当点击按钮时获取用户信息
<button open-type="getUserInfo" bindgetuserinfo="getUserInfo">获取用户信息</button>
bindgetuserinfo只有与open-type = "getUserInfo"绑定使用才有效。
index.js中的方法代码
getUserInfo: function(e)
{
console.log(e.detail.userInfo)
}
效果展示