Vue+webpack+vue-router+nginx部署

 

1、把webpack生成的静态文件copy到服务器就行了

2、vue-router的配置

//创建路由
export default new Router({
  // mode:'history',  
  base: '/project-name/',
  routes: constantRouterMap
});
mode:'history':当你使用 history 模式时,URL 就像正常的 url,例如 http://yoursite.com/user/id,也好看!使用该模式,刷新发出http请求不会请求路由,会显示404,所以呢,你要在服务端增加一个覆盖所有情况的候选资源:如果 URL 匹配不到任何静态资源,则应该返回同一个 index.html 页面,这个页面就是你 app 依赖的页面。
需要在nginx配置文件中添加重定向页面:
        location / {
            #root   html;
            root E:/dist;
            index  index.html index.htm;            
            try_files $uri $uri/ /index.html;
        } 

 

posted on 2020-04-09 16:13  苏上话  阅读(566)  评论(0编辑  收藏  举报