Coder Social home page Coder Social logo

异步路由加载到head about qiankun HOT 8 CLOSED

umijs avatar umijs commented on May 17, 2024
异步路由加载到head

from qiankun.

Comments (8)

kuitos avatar kuitos commented on May 17, 2024

提供一个最小可复现的 repo?

from qiankun.

chenfengjw163 avatar chenfengjw163 commented on May 17, 2024

repo: https://github.com/chenfengjw163/qk-demo
main文件夹为portal项目,react16为子应用
复现步骤:

  1. main、react16文件夹分别安装依赖
  2. 根目录执行yarn start或者npm run start
  3. 打开http://localhost:7099 ,点击页面中的page2超链接
  4. 查看元素,head中存在localhost:7100/Page2.chunk.js和Page2.chunk.css

造成原因:
webpack支持code split,异步加载的文件会在head中新增一个link或者script标签。当子应用卸载后head中的标签并不会被移除,js文件倒还好,css文件会造成全局污染

from qiankun.

kuitos avatar kuitos commented on May 17, 2024

收到,近期会支持。如果有 block 到你的开发,可以临时先把 code split 关掉,我们这边发版本后再开启

from qiankun.

chenfengjw163 avatar chenfengjw163 commented on May 17, 2024

是否可以提供下解决思路,在qiankun还没发布前,我们可以先自己适配下

from qiankun.

kuitos avatar kuitos commented on May 17, 2024

如果 css 地址固定的话,可以在 unmout 阶段手动移除相关的 css 节点

from qiankun.

chenfengjw163 avatar chenfengjw163 commented on May 17, 2024

之前考虑过一个方案,在加载子应用之前遍历head的节点,卸载子应用时,移除掉除了这些子节点以外的节点

from qiankun.

chenfengjw163 avatar chenfengjw163 commented on May 17, 2024

#51 支持子应用code split

from qiankun.

peterzhai avatar peterzhai commented on May 17, 2024

现在我需要将样式加载到body->header,现在的新版本全加到子应用了。而我的项目是按路由加载 同一个项目的子应用。结果删除一个子应用,一开始加载的样式没了,影响到了剩下的子应用

from qiankun.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.