router.js
const router = createRouter({
// history: createWebHistory(process.env.BASE_URL),
history: createWebHistory(),
base:'./',
routes
})
config.js
把publicPath打开
在nginx的nginx.conf中
# vue history模式nginx配置
server {
listen 80;
server_name convenients.code.com;#自己本地可以写成127.0.0.1
location / {
root convenients;
try_files $uri $uri/ /index.html;
# 这里rewrite ,如果在上面第一步在打包时处理了,就不用了
#rewrite ^/assets/(.*)$ /web/static/assets/$1 break;
}
}
上述为服务器刷新失去页面解决办法,本地刷新失去页面注意一下是不是本地跑的时候把它打开了
还不知道为什么,但是打开的话本地刷新就不好使了= =