vue2中使用abortcontroller.abort()不生效?

调用this.controller.abort()时没反应,代码如下

//api.js
async function zhinenghegao(fileName, filePath, meetingId, signal) {
  return await https.get(
    `/meeting-service/file/check?fileName=${fileName}&filePath=${filePath}&meetingId=${meetingId}`,
    {
      signal:signal
    }
  );
}
//.vue
data(){
    return {
        controller:new AbortController()
    }
},
methods:{
     async hegao() {
      try {
        let res = await api.meeting.zhinenghegao(
          file.name,
          file.url,
          this.meetingId,
          this.controller.signal
        );
      } catch (e) {
      }
    },
    hegaoCancel() {
      this.$Modal.confirm({
        title: "提醒",
        content: "",
        okText: "确认",
        onOk: () => {
          console.log(this.controller.abort)
          this.controller.abort()
        },
        onCancel: () => {}
      });
    },
}
阅读 529
1 个回答

看下https的封装呢

推荐问题
宣传栏