Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How does vue create a routing instance

Shulou Source: shulou.com Published: 2022-05-31 13:24:57 09月21日 Update

This article mainly explains "how to create a routing instance in vue". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to create routing instances with vue".

The specific steps are as follows:

1. First, create a new html project and introduce vue and vue-router into the project

Import Vue from 'vue'

Import Router from 'vue-router'

After the introduction of 2.vue and vue-router, use the Vue.use method to register routes in the project

Vue.use (Router)

3. After the route is registered, define a route in the project

Export default new Router ({

Routes: [

{

Path:'/

Name: 'Home'

Component: Home

}

{

Path:'/ content'

Name: 'Content'

Component: Content

}

]

Mode: "history"

})

4. Finally, after the route is defined, you can use the new VueRouter method to create an instance for the route

Const router = new VueRouter ({routes})

New Vue ({

El:'# app'

Data: {

}

Methods: {

}

Router

})

At this point, I believe you have a deeper understanding of "how to create routing instances in vue". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Routing instance project method content learning practical deeper interest practicality practical easy to operate more friends steps website channel query Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Shulou Technology Shulou Tech Info Shulou Information MySQL