学习_$http与promise

发布时间 2023-06-04 22:52:30作者: xiaoxinZard
      await this.$http.post('vectorDataToImage', {
        vector_file_path: vectorLUDataInPath,
        field_name: 'LUTypeCode',
        img_output_path: outPutfolderPath,
        color_list: ['#fff0', '#ff0000', '#bb9674', '#ffff2d', '#006380', '#9c9c9c'],
      }).then((res => {
        if(res.status === 200){}
        imgRes = res.data
        console.log("successRes = ", res)
      }),(error => {
        console.log(error)
      }))

之前不太明白是不是axios中为$http声明了两个callback,并指定其为success callback 和 failed callback。

然后查询promise文档得知,callback不是axios中声明的,而是promise.then中声明的。

 参考资料:https://juejin.cn/post/7108187709076111367