vue method中async await解决回调

// 采取async await 方式调用
    async getdetails() {
      
      // 异常需要通过try catch捕获
      try {
        const getData = {
          projectId: this.projectId,
        };
        let location = await getProjectId(getData);
        if (location.data) {
          let name =location.data.name;
          let result = await postProjectDetails(data);
          if (result.data) {
          }
        }
      } catch (err) {
        console.log(err);
      }
    },

  

posted @ 2021-03-16 15:18  玉文  阅读(1287)  评论(0编辑  收藏  举报