mpvue 小程序获取用户信息

时间:2019-08-30 21:01:59   收藏:0   阅读:349
<button open-type="getUserInfo" @getuserinfo="getUserInfo">登录</button>
  methods: {
    getUserInfo: function(e) {
    console.log(e) wx.setStorageSync(
"nickname", e.mp.detail.userInfo.nickName); wx.setStorageSync("avatarUrl", e.mp.detail.userInfo.avatarUrl); }, login() { if (!wx.getStorageSync("nickname")) { wx.login({ success: function(res) {
        console.log(res)
      } }); } } }, created() {
this.login(); },

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!