vue打包以后,除了首页意外,其余页面是空白

针对vue项目打包以后,除了首页意外,其余页面是空白的,需要在服务端进行配置。

原因是router中,mode是history引起的

如果是nginx,改成如下:

location / {
            root /workspace/shop/client/dist;
            try_files $uri $uri/ /index.html;
           # error_page 404 /index.html;
        }

  

参考链接:https://router.vuejs.org/zh/guide/essentials/history-mode.html#%E5%90%8E%E7%AB%AF%E9%85%8D%E7%BD%AE%E4%BE%8B%E5%AD%90

原文地址:https://www.cnblogs.com/karila/p/10001410.html