Change 404 page in vuepress

心不动则不痛 提交于 2020-05-15 02:03:17

问题


Is it possible to change / customize the 404 page of Vuepress without ejecting and having to change the whole theme?

I am currently using the enhanceApp.js, but I'm unsure how I can change the router options (the catchall route) as the Router is already created. The way I got it working right now is this:

router.beforeEach((to, from, next) => {
  if (to.matched.length > 0 && to.matched[0].path === "*") {
    next("/404.html");
  } else {
    next();
  }
});

However, this feels like a hack as I always redirect to a custom and existing page containing my 404. Is there a more official way to do this?

来源:https://stackoverflow.com/questions/51702549/change-404-page-in-vuepress

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!