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

z2acfund  于 22天前  发布在  其他
关注(0)|答案(1)|浏览(16)

本人遇到 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)

z6psavjg

z6psavjg1#

@PanJiaChen quick fix, PR opened just needs a merge

相关问题