微信小程序添加数据到数据库

这是getUserProfile事件的代码



```javascript
getUserProfile(e) {
    wx.getUserProfile({
      desc: '获取你的昵称、头像、地区及性别', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
      success: (res) => {
        // console.log(res);
        this.setData({
          userInfo: res.userInfo,
          hasUserInfo: true,
        })
      },
    })
   

这里是想把获取到的数据添加到数据库,但是这样写的话,userInfo好像获取不到

```javascript

let userInfo=this.userInfo;
    if(!this.data.hasUserInfo && userInfo){
      db.collection('users').add({
        data:{
          userPic:userInfo.avatarUrl,
          nickname:userInfo.nickName,

这是getUserProfile打印出的值,求问这个情况下想获取到userInfo该怎么写路径呀,我这样写(let userInfo=this.userInfo;)是错误的

img