Get the App
SLTechnology News&Howtos  ›  Development  › 

How to install routing in vue

Shulou Source: shulou.com Published: 2022-06-01 03:45:17 10月31日 Update

This article mainly explains "how to install routing in vue". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's ideas to study and learn how to install routing in vue.

In vue, routing is installed through the "npm install vue-router-- save" command; npm is a package management tool, and the "npm install" command installs the specified packet in a specified directory, and "vue-router" routing determines the path of the packet from the source to the destination.

This article operating environment: windows10 system, Vue2.9.6 version, DELL G3 computer.

What command does vue use to install routing

Routing uses installation steps

Step 1: install vue-router

Npm install vue-router-save

Step 2: use it in a modular project (because it is a plug-in, you can install the routing function through Vue.use0)

Step 1: import the routing object in the index.js file in the router directory and call the

Import Router from 'vue-router' Vue.use (VueRouter)

Step 2: create a routing instance. And export routes, using routers to set routing configuration information

Export default new Router ({/ / create routing object routes: [{path:'/', name: 'HelloWorld', component: HelloWorld}]})

Step 3: import routes in the Vue instance and mount the created route instance

Import router from'. / router' / / Import route new Vue ({el:'# app', router,// mount route})

The difference between whether a route is used or not

Thank you for reading, the above is the content of "how to install routing in vue". After the study of this article, I believe you have a deeper understanding of how to install routing in vue, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Routing commands instances steps learning content objects that is directories guides information functions available through tools projects ideas situations plug-ins data files Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Information OPPO Reno Shulou Technology Microsoft