From the course: Building Laravel and Vue.js 2 Web Apps

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Enabling Vue Router history mode

Enabling Vue Router history mode

From the course: Building Laravel and Vue.js 2 Web Apps

Start my 1-month free trial

Enabling Vue Router history mode

- [Instructor] In this video, we'll enable Vue Router's history mode for cleaner URLs and we'll also build out our menu item form for adding new items to a category. If you want more SEO friendly URLs, or if you just prefer not to use this hash base routing, you can remove it easily and enable Vue Router's history mode by setting the mode option to history. In our case, we'll also want to change this slash path to menu editor since routing will be based on the actual URL now. So now when I go back to the browser and navigate to menu editor, we're redirected to just/categories. And I can click add item now and the URL's just/additem. So I can click back and forth and use these nice URLs and I'm always in the router on the menu editor page. But this will create a conflict with our original categories page. From inside our menu editor, Vue Router can intercept requests for /categories in router links but if we go up to the address bar and navigate to /categories directly if I hit enter…

Contents