alibaba / alibaba/lowcode-engine

Preview 放在spa项目中 切换路由后回来会把相同js和css资源重新放入head标签中,有优化方案吗

Open
#1,827 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
15.9k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

## **Describe the bug (required)** / **详细描述 bug(必填)**

在spa项目中,把预览组件Preview 放在某个路由下, 切换路由后回来会把相同js和css资源重新放入head标签中,这样就会无限叠加,
![image](https://user-images.githubusercontent.com/29122164/228783855-a9dd36bf-c7ac-418d-93a5-c24d3ba162df.png)

目前能想到的就是assetLoader.load的时候判断head已经有相同的link和script就不引入,但是componentName为page的css每次会自动引入,css传空也会引入,是否已经有其他的优化方案了。

---

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the Preview component in an SPA, navigating away, and returning to its route while inspecting the document head. Trace assetLoader.load and the componentName=page CSS handling; done means repeated navigation no longer appends duplicate JavaScript or CSS resources, including when the CSS value is empty.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.