Router modes

We can change the router mode with the mode parameter in the constructor options. It can either be 'hash' (default), 'history', or 'abstract'.

The hash mode is the default we are already using. It is the "safest" choice since it is compatible with any browser and server. It consists of using the "hash" part of the URL (which means the part after the sharp character) and change it or react to changes to it. The big advantage is that changing the hash part will not change the real web page where our app is running (which would be very unfortunate). The obvious drawback is that it forces us to separate the URL in two with the not so pretty sharp symbol.

Thanks to the HTML5 history.pushState API, we can get rid of this sharp character ...

Get Vue.js 2 Web Development Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.