Skip to content

Instantly share code, notes, and snippets.

@chandu
Created January 25, 2017 19:34
Show Gist options
  • Select an option

  • Save chandu/dcc4954c948d0a2749b46e9c831e0332 to your computer and use it in GitHub Desktop.

Select an option

Save chandu/dcc4954c948d0a2749b46e9c831e0332 to your computer and use it in GitHub Desktop.
const PageNotFoundComponent = {
template: `
<div class="alert alert-danger" role="alert">
<h1>Page {{notFoundRoute}} not found</h1>
We tried hard, but unfotunately could not find a page that matches your request. :(
</div>
`,
data() {
return {
notFoundRoute: ""
}
},
beforeRouteEnter (to, from, next) {
console.log(to);
next(vm => vm.notFoundRoute = to.path);
},
beforeRouteUpdate (to, from, next) {
console.log(to);
console.log(from);
notFoundRoute = to;
next();
},
}
const routes = [
{path: "/home", component: AppComponent},
{path: "*", component: PageNotFoundComponent, props: true}
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment