后台:页面刷新的四种方式与404页面匹配

方式1,2:go(0)和reload()

通过window.location.reload()或是router.go(0)两种强制刷新方式,相当于按F5,会出现瞬间白屏,体验差,不推荐。

方式3:定义一个空白路由页面,路由跳转到该空白页后立马跳回当前页,实现路由刷新

 {
    path: '/redirect',
    component: Layout,
    meta: { hidden: true },
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index.vue')
      }
    ]
  },

redirect/index.vue




                    
                    

你可能感兴趣的:(javascript,vue.js,前端)