Vue3+.NET6 Practical Huahua Network E-commerce Project (2)

1. Web page module division

Create a new folder in the src directory named views, create a new file in the views folder, and end with .vue

under the component

2. Routing configuration and use

  1. The role of routing

Adaptation of the URL address and the page (changing the web page address will also change)

  1. install command

npm install vue-router@next --save

  1. Create a new routing file routes.ts in the src directory, press the right button to write the code block into the page and the routing mapping relationship

Create a new file routes in the src directory

Import the package and write down the corresponding path in this file

Note: All modules must be exported if they are imported, otherwise an error will be reported export default router

  1. Then write the code in the main function to use routing

import router from './routes' import route

app.use(router) uses routing

  1. Introduce <router-view></router-view> in App.vue

Guess you like

Origin blog.csdn.net/qq_71012549/article/details/128737322