Router

Article Directory

Router

Install and use vue-router
If you don't need scaffolding, we use the command npm install vue-router --save to install

When we use scaffolding to build the project, we don't need to use the above command to install, because as long as we choose whether to choose the route when we build the project, the project will
automatically install the route for us.

Route map

First, let's take a look at how to use routing for routing mapping in the App.vue component as shown below:

Insert picture description here

Insert picture description here

Insert picture description here

The mapping path configured in the index.js file of the route is as follows:

Insert picture description here

The push and replace methods are used in routing to directly jump to components and the difference between push and replace methods:

Insert picture description here

If you use the replace method, you can also jump to the corresponding component, but you cannot go back to the browser.

The set global css style is as follows:

Insert picture description here

Routing nesting

Insert picture description here

Insert picture description here

Insert picture description here

Insert picture description here

The path corresponding to :index is as follows:

Insert picture description here

The nested components corresponding to the above path are as follows:

Insert picture description here

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_45950109/article/details/111943471