From 6ee30af722020a1c8fc2dd8ef5028217ff8c6c7a Mon Sep 17 00:00:00 2001 From: Rui Wu Date: Thu, 8 Aug 2024 21:45:37 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E5=8F=96=E6=B6=88=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20AbortController=20=E7=AC=AC=E4=BA=8C?= =?UTF-8?q?=E7=A7=8D=E7=94=A8=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/advanced/cancellation.md | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/docs/advanced/cancellation.md b/docs/advanced/cancellation.md index 242acc2..1b59531 100644 --- a/docs/advanced/cancellation.md +++ b/docs/advanced/cancellation.md @@ -2,14 +2,42 @@ ## AbortController -支持使用 [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) 取消请求。要使用 AbortController,请使用 [abort-controller polyfill](https://github.com/mysticatea/abort-controller)。 +支持使用 [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) 取消请求。要使用 AbortController,请使用 Polyfill。 + +### abortcontroller-polyfill ::: code-group ```sh [npm] -npm add abort-controller@^3.0.0 +npm install abortcontroller-polyfill@^1.7.5 +``` + +```sh [yarn] +yarn add abortcontroller-polyfill@^1.7.5 +``` + +````sh [pnpm] +pnpm add abortcontroller-polyfill@^1.7.5 + +::: + +在 `App.vue` 中仅可能早地导入,后续可全局使用。 + +```vue + ``` +### abort-controller + +::: code-group + +```sh [npm] +npm install abort-controller@^3.0.0 +```` + ```sh [yarn] yarn add abort-controller@^3.0.0 ``` @@ -20,8 +48,11 @@ pnpm add abort-controller@^3.0.0 ::: +必须导入后使用,不可全局使用。 + ```typescript import { un } from '@uni-helper/uni-network'; +// 必须导入后使用 import AbortController from 'abort-controller/dist/abort-controller'; // ❌ 错误做法 1 // import AbortController from 'abort-controller';