美文网首页
vue-cli打包后的项目服务器布署

vue-cli打包后的项目服务器布署

作者: shawbs | 来源:发表于2017-11-16 12:03 被阅读0次

参考自 https://www.zhihu.com/question/46630687

如果放置在服务器环境非根目录下,则需要:

1 修改config/index.js

build: {
    ...
    // assetsPublicPath: '/',
    assetsPublicPath: '/dist/', //加上服务器下项目的根目录

2 route配置文件

export default new Router({
  // mode: 'history',
  base: '/dist/',
  routes
})

在history模式,地址栏输入 'http://xxx.com/xxx/xxx' 访问, 会进行http请求,因为资源路径不存在,所以报404.
解决方法有:
方法1, 将所有请求 转到 'http://xxx.com/index.html'
方法2, 不使用 history模式

相关文章

网友评论

      本文标题:vue-cli打包后的项目服务器布署

      本文链接:https://www.haomeiwen.com/subject/utrlvxtx.html