in VueJS

VueJS: Redirect Unmatched Routes To 404

Like any other website if the router can not find the URL you're navigating to then you need to display a 404 page to your user for them to know this page doesn't exist anymore. You can redirect any unmatched route to a 404 page in Vue by add the following code snippet to the bottom of your route object.

{ path: '*', component: require('./views/404.vue') }

This will match on all URLs, and display the component for a 404.vue component. This is important that it

Upgrade to access all content on Paulund

Members unlock all tutorials and snippets

Access to all downloadable content

Access to code examples before others

Sign Up Now

Already a member? Login here

Subscribe To The Weekly Newsletter

Get weekly updates to your email