场景

首先定义一个方法并使用 async和 await,然后 通过this调用这个方法并获取值

1定义一个方法

async WorkerOrderimg(e) {
        const { data } = await getWorkerOrderimg(e)
        return data
      },

2.调用

// tabs 切换
      handleClick(e) {
        let _this = this
        this.formData.eid = this.Enterinfo.id
        switch (e.name) {
          case 'scss':
            _this.formData.label = 50
            let workimgs = _this.WorkerOrderimg(this.formData)
            this.shengchanList = []
            if (workimgs.data) {
              for (let i in workimgs.data) {
                _this.shengchanList.push(workimgs.data[i].fileurl)
              }
            }
            console.log(workimgs)
            break
          default:
        }
      },

这个是控制台是打印出来是这种

3.通过.then()获取

// tabs 切换
      handleClick(e) {
        let _this = this
        this.formData.eid = this.Enterinfo.id
        switch (e.name) {
          case 'fqss':
            _this.formData.label = 47
            _this.WorkerOrderimg(this.formData).then( data => {
              this.feiqiList = []
              if (data) {
                for (let i in data) {
                  _this.feiqiList.push(data[i].fileurl)
                }
              }
            })
            break
          default:
        }
      },

Logo

前往低代码交流专区

更多推荐