Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Routing to a Vue.js cli 3.0 app

The new Vue.js 3.0 plugin architecture is nice, but it seems to to be missing a router plugin. If I choose not to install routing when I first create the project (vue create my-project), I'd expect that I could change my mind later and add routing with something like vue add @vue/router, but that plugin doesn't appear to exist. Is there a way to add routing from the CLI after the fact?

like image 280
Jim Cooper Avatar asked Apr 30 '18 23:04

Jim Cooper


People also ask

How do I add a path to Vue?

To use vue as command in cmd. Open the cmd as admin and run the the following command. setx /M path "%path%;%appdata%\npm" Now restart the cmd and run the vue again. It should work just fine.

Does Vue have routing?

Simple Routing from Scratch If you only need very simple routing and do not wish to involve a full-featured router library, you can do so with Dynamic Components and update the current component state by listening to browser hashchange events or using the History API.


Video Answer


1 Answers

After some experimenting with vue-cli3, i found that you can use vue add to setup components you missed.

Use vue add router That set up the routing and created some sample components Home and About.

This also work for other modules like adding vuetify with vue add vuetify. You can read more about vue add from the plugins and presets guide

like image 133
Isaac Obella Avatar answered Nov 12 '22 00:11

Isaac Obella