Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

路由导致取public资源路径错误 #487

Closed
szmaozi opened this issue Apr 16, 2021 · 0 comments
Closed

路由导致取public资源路径错误 #487

szmaozi opened this issue Apr 16, 2021 · 0 comments

Comments

@szmaozi
Copy link

szmaozi commented Apr 16, 2021

Describe the bug

路由导致取public资源路径错误

  1. 如果是hash模式,并且在#前误输入其他字符串,则会导致该页面申请public资源文件时,url错误。
    如:http://localhost:3100/aaa/#/bbb: 访问bbb页面如果有public资源文件请求,则url会组成:http://localhost:3100/aaa/resource/...... (多了/#/前面的误输入字符串)
  2. 如果更改版本路由为history模式,该页面如果申请public资源文件url也会组错。

Reproduction

取得v2.3.0版本(最新版本),以组件富文本tinymce为例:

  1. 如果输入url:http://localhost:3101/test/aaaa/#/comp/editor/tinymce/index 则报错:
tinymce.js:1795 GET http://localhost:3101/test/aaaa/resource/tinymce/skins/ui/oxide/skin.min.css net::ERR_ABORTED 404 (Not Found)
tinymce.js:1795 GET http://localhost:3101/test/aaaa/resource/tinymce/skins/ui/oxide/content.min.css net::ERR_ABORTED 404 (Not Found)
  1. 如果更改路由模式为history:
    更改src/router/index.ts
// app router
const router = createRouter({
  // history: createWebHashHistory(import.meta.env.VITE_PUBLIC_PATH),
  history: createWebHistory(import.meta.env.VITE_PUBLIC_PATH),
  routes: (basicRoutes as unknown) as RouteRecordRaw[],
  strict: true,
  scrollBehavior: () => ({ left: 0, top: 0 }),
});

输入url地址:http://localhost:3100/comp/editor/tinymce/index
报错:

tinymce.js:1795 GET http://localhost:3100/comp/editor/tinymce/resource/tinymce/skins/ui/oxide/skin.min.css net::ERR_ABORTED 404 (Not Found)
tinymce.js:1795 GET http://localhost:3100/comp/editor/tinymce/resource/tinymce/skins/ui/oxide/content.min.css net::ERR_ABORTED 404 (Not Found)

System Info

  • Operating System: win10
  • Node version: v2.3.0
  • Package manager (npm/yarn/pnpm) and version: yarn-1.22.10
@anncwb anncwb closed this as completed in a863ad4 Apr 16, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Sep 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant