From b86fffcdbea49526e2256024ac776336aa7a61c3 Mon Sep 17 00:00:00 2001 From: gongshun <2440606146@qq.com> Date: Wed, 27 Oct 2021 21:25:18 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20modified=20example=20of=20custom?= =?UTF-8?q?=20fetch=20(#1779)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kuitos --- docs/faq/README.md | 65 +++++++++++++++++++++++++++++++++++++++++++ docs/faq/README.zh.md | 2 +- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/docs/faq/README.md b/docs/faq/README.md index 38a9f63..f73d822 100644 --- a/docs/faq/README.md +++ b/docs/faq/README.md @@ -477,6 +477,71 @@ Since qiankun get assets which imported by sub app via fetch, these static resou See [Enable Nginx Cors](https://enable-cors.org/server_nginx.html). +## How to solve that micro apps loaded failed due to abnormal scripts inserted dynamically by carriers + +Scripts inserted by carriers are usually marked with `async` to avoid loading of block micro apps. This is usually no problem, such as: + +```html + +``` + +However, if some inserted scripts are not marked as `async`, once such scripts fail to run, the entire application will be blocked and subsequent scripts will no longer be executed. We can solve this problem in the following ways: + +### Use a custom `getTemplate` method + +Filter abnormal scripts in the HTML template of the micro app through the `getTemplate` method implemented by yourself. + +```js +import { start } from 'qiankun'; + +start({ + getTemplate(tpl) { + return tpl.replace('