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

本人遇到 mode:'history' 模式 下的404问题,可以给你参考一下。 #3289

Open
Iblis18565381858 opened this issue Jun 29, 2020 · 1 comment

Comments

@Iblis18565381858
Copy link

本人遇到 mode:'history' 模式 下的404问题,可以给你参考一下。
当在vue.config.js 配置 publicPath: '/public/' 的时候,虽然资源文件能加载到,但是路由一直跳转404,是因为路由还是localhost:4200/xxx,而不是根据publicPath来转变成localhost:4200/public/xxx。解决办法是:在router/index.js还需要加入 base: /public,可以配置到环境变量就是

const createRouter = () => new Router({
  base: process.env.VUE_APP_SRC,
  mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

Originally posted by @PhotonAlpha in #2812 (comment)

dseeker added a commit to dseeker/vue-element-admin that referenced this issue Nov 8, 2020
fixes breaking to 404 page in history mode when publicPath sub path is set
@dseeker
Copy link

dseeker commented Nov 8, 2020

@PanJiaChen quick fix, PR opened just needs a merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants