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:
The mapping path configured in the index.js file of the route is as follows:
The push and replace methods are used in routing to directly jump to components and the difference between push and replace methods:
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:
Routing nesting
The path corresponding to :index is as follows:
The nested components corresponding to the above path are as follows: