vue2.0构建项目,
默认不做配置,使用是hash模式,地址栏上有个“/#/”号,like http://localhost:8000/#/login 这样.
官网文档使用history模式可以去掉#,样子like http://localhost:8000/login 这样.
history模式下:
当项目,在nginx上运行页面时,由于history模式的链接url是伪静态 路由地址都是虚拟地址,
直接访问找不到,会报404错误,需要rewrite url规则来支持。
方法一:在nginx上:修改nginx的配置文件,vim /usr/local/nginx/conf/nginx.conf
location / {
#......
#所要添加的配置代码
try_files $uri $uri/ /index.html;
}
方法二:注释掉history
export default new Router({
// mode: 'history',
routes: routes,
})
能力不足水平有限
有问题别讲脏话骂人
来学习交流
有问必答
email:1848199654@qq.com