VUE路由history模式坑记--NGINX
因微信分享和自动登录需要, 对于URL中存在'#'的地址,处理起来比较坑(需要手动写一些代码来处理)。还有可能会有一些隐藏的问题没被发现。 如果VUE能像其他(JSP/PHP)系统的路径一样,就不存在这些问题了。 对于VUE的router[mode: history]模式在开发的时候,一般都不出问题。是因为开发时用的服务器为node,Dev环境中自然已配置好了。 但对于放到nginx下运行的时候,自然还会有其他注意的地方。总结如下: 在nginx里配置了以下配置后, 可能首页没有问题,链接也没有问题,但在点击刷新后,页面就无法显示了(404) location / { root /data/nginx/ html; index index.html index.htm; } 为了解决404,需要通过以下两种方式: 方式一 location / { root /data/nginx/ html; index index.html index.htm; error_page 404 / index.html; } 方式二 location / { root /data/nginx/ html; index index.html index.htm; if (!- e $request_filename) { rewrite ^/(.*) / index.html last; break