比如网址为www.baidu/home 即为主域名,此时我们将打包的静态文件放在此域名的根目录下时只需在nginx文件中添加
location / { // 此行在这个最下面 if (!-e $request_filename) { rewrite ^/(.*) /index.html last; break; } }
若为二级域名(www.baidu/test/home)则我们需要修改两个位置 1.router.js文件中mode下面添加
base:”test"
2.nginx
location /test/ { // 此行在这个最下面 if (!-e $request_filename) { rewrite ^/(.*) /test/index.html last; break; } }
本文作者为lishengyu,转载请注明。