大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE稳定放心使用
vue页面访问正常,但是一刷新就会404的问题解决办法:
第一种解决方法:
将vue路由模式mode: ‘history’ 修改为 mode: ‘hash’
//router.js文件
const router = new Router({
//mode: 'history',
mode: 'hash',
routes: [
{ path: '/', redirect: '/login' },
{ path: '/login', component: Login },
]
})
第二种解决方法:
在服务器Nginx
配置文件里,添加如下代码,再刷新就OK了
location / {
try_files $uri $uri/ @router;
index index.html;
}
location @router {
rewrite ^.*$ /index.html last;
}
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/183530.html原文链接:https://javaforall.net