vue-router 默认 hash 模式 —— 使用 URL 的 hash 来模拟一个完整的 URL,于是当 URL 改变时,页面不会重新加载。
如果不想要很丑的 hash,我们可以用路由的 history 模式,这种模式充分利用 history.pushState API 来完成 URL 跳转而无须重新加载页面。
但是history需要服务端配合,否则不是放在服务器根目录下则访问不到
ngnix配置如下:
// cuttlefishH5 就是二级目录的名称location /cuttlefishH5/ {
if (!-e $request_filename) {
rewrite ^/(.*) /cuttlefishH5/index.html last; break;
}
root /data/www/web/cuttlefish-product;
index index.html
index.htm;
}