nginx运维——vue.js前端刷新出现404问题的处理

第一种解决方式;

改vue的路由为hash模式

vue中加入404页面的路由

const router = new VueRouter({
  mode: 'history',
  routes: [
    { path: '*', component: NotFoundComponent }
  ]
})

第二种解决方式:

改nginx配置文件,加入一行即可

location / {
  try_files $uri $uri/ /index.html;
}

Categories: 系统运维