mpvue 小程序获取用户信息

<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(); },

 

posted @ 2019-08-30 20:14  绿谷  阅读(846)  评论(0编辑  收藏  举报