How to do it…

First, you'll install a compact server for SPAs so that history mode will work.

In your favorite command line, go inside the directory that will contain your application. Then, type the following commands:

    npm install -g history-server    history-server .

After the server is run, you will have to point your browser to http://localhost:8080 and if you have a file called index.html in your directory, it will be shown; otherwise you won't see much.

Create a file called index.html and fill in some boilerplate, like in the Choosing a development environment recipe. We want an empty page with only Vue and vue-router as dependencies. Our empty canvas should look like this:

<!DOCTYPE html><html><head> <script src="https://unpkg.com/vue/dist/vue.js"></script> ...

Get Vue.js 2 Cookbook 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.