收藏
回答

setStorage fail

```

toChat: function ({ currentTarget }) {

           const { userid: otherUserID } = currentTarget.dataset;

           const { postId, viewerId } = this.data;

           this._createConversation(otherUserID, postId);

           if (!this.data.isChatted) {

               wx.getStorage({

                   key: `${postId}_viewer`,

                   success: res => {

                       wx.setStorage({

                           key: `${this.data.postId}_viewer`,

                           data: {

                               ...res.data,

                               [viewerId]: true,

                           },

                           success: () => {

                               setTimeout(() => {

                                   this.setData({

                                       isChatted: true,

                                   });

                               }, 1500);

                           },

                           fail: e => {

                               throw new Error(e);

                           },

                       });

                   },

                   fail: e => {

                       throw new Error(e);

                   },

               });

           }

       },

```



我们在一台iphone x max 上得到这个报错,在其他人的手机上正常,请问可能是什么问题,该如何解决



回答关注问题邀请回答
收藏

4 个回答

  • 禾店短剧系统
    禾店短剧系统
    2021-06-11

    :Storage和StorageSync的写法是不一样的


    1、setStorageSync(同步)


    wx.setStorageSync("uname", that.data.name );

    getStorageSync(同步)


     wx.setStorageSync('uname')

    2、setStorage


    wx.setStorage({

     

      key:"uname",

     

      data:that.data.name

     

    })

    getStorage


    wx.getStorage({

      key: 'uname',

    })


    2021-06-11
    有用 1
    回复
  • Mimi
    Mimi
    2019-07-29

    +1 同样的问题

    2019-07-29
    有用 1
    回复
  • 灵芝
    灵芝
    2019-04-22

    麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

    2019-04-22
    有用
    回复 2
    • Kelly
      Kelly
      2020-07-17
      这问题还没有解决吗,都一年多了?
      2020-07-17
      回复
    • 灵芝
      灵芝
      2020-07-20回复Kelly
      若有问题,请单独发帖反馈
      2020-07-20
      回复
  • 祺爸💎
    祺爸💎
    2019-04-22

    回调里不要再用this了,先在回调外面let that=this

    2019-04-22
    有用
    回复 1
    • 2019-04-22

      但this已经用箭头函数绑定了啊,应该不存在这个问题。况且若是this不对应该会报read setData from undefined,或是undefined is not a function 吧

      2019-04-22
      回复
登录 后发表内容