Vue-router 中有hash模式和history模式,vue的路由默认是hash模式,hash 模式和 history 模式都属于浏览器自身的特性
vue 路由配置
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes
})
Nginx 配置 解决刷新页面出现404问题
server {
listen 80;
server_name localhost;
location / {
root /opt/dist; #默认访问目录
index index.html index.htm; #默认访问文件
try_files $uri $uri/ /index.html; #目录不存在则执行index.htm
}
}