solve the problem of losing style when refresh page of multi-level routing path under React or Vue

created at 11-12-2021 views: 65


Routing uses BrowserRouter mode

Introduced styles in index.html

1. Modify path 1

Do not write ./ when importing styles in public/index.html, use / (commonly used)

2. Modify path 2

In React

Do not write / write %PUBLIC_URL% (commonly used) when importing styles in public/index.html

In Vue

Don’t write / write <%= BASE_URL %> (commonly used) when introducing styles in public/index.html

3. Change the routing mode

Use HashRouter

created at:11-12-2021
edited at: 11-12-2021: