收藏
回答

request调用setcd就报错?

setCD : function(){
      // 获取页面数据
      let ruku = this.data.ruku;
      let chuku = this.data.chuku;
      let os = this.data.os;
      let arm = this.data.arm;
      let clipboardData = '';
      let tempVariableA = new Date().toLocaleString();
      let tempVariableB = "";
      let tempVariableC = "";
      let fault = this.data.choiseId;
      if (fault) {
        if (chuku.some(item => item.id === fault)) {
          tempVariableB = "出库";
        } else if (ruku.some(item => item.id === fault)) {
          tempVariableB = "入库";
        } else if (os.some(item => item.id === fault)) {
          tempVariableB = "";
        }
      };
      if (arm) {
        tempVariableC = ruku.find(item => item.id === arm)?.name || "";
      };
      clipboardData = tempVariableA + "\n" + tempVariableB + tempVariableC + "发生故障";
      wx.setClipboardData({
        data: clipboardData,
        success (res) {
          wx.getClipboardData({
            success (res) {
              wx.showToast({
                title'故障信息已经复制到粘贴板',
                icon'success',
                duration3000
              });
            }
          })
        }
      });
},
    wx.request({
      urlthis.data.url,
      method'POST',
      data: jsonData,
      successfunction(res{
        console.log(res.data);
        this.setCD();
        wx.showToast({
          title'提交成功',
          icon'success',
          duration3000
        });
      },
      failfunction(error{
        console.log(error);
      }
    });

 request调用setcd就报错


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

1 个回答

  • Mr.Zhao
    Mr.Zhao
    2023-08-30

    setcd 是啥

    2023-08-30
    有用
    回复 4
    • 显龙
      显龙
      2023-08-30
      就是那个function
      2023-08-30
      回复
    • Mr.Zhao
      Mr.Zhao
      2023-08-31回复显龙
      报啥错呢
      2023-08-31
      回复
    • 显龙
      显龙
      2023-08-31回复Mr.Zhao
      WAServiceMainContext.js:2 TypeError: Cannot read property 'setCD' of undefined
      2023-08-31
      回复
    • Mr.Zhao
      Mr.Zhao
      2023-08-31回复显龙
      跟request没关系,this指针问题,外层定义const that = this;  this.setcd 改成that.setcd就行了
      2023-08-31
      回复
登录 后发表内容