Getting Started with Vue Scaffolding and Routing

1. Vue scaffolding

  1. Install vue scaffolding
    01 nodejs installation
    02 Scaffolding global installation npm i -g @vue/cli
    03 Check whether the installation is successful vue -V
  2. Create a project
    01 Switch to the root directory/the directory where the project needs to be located cd/
    02 vue create myvue Create a myvue project
  3. Run the project
    01 cd myvue switch to the project directory
    02 npm run serve run the project

2. Routing

  1. Built-in component
    01 router-view stores the page
    02 router-link changes the address bar and changes the hash valueThe to attribute changes the address bar
  2. /router/index.js routing configuration
    {path:"/",//配置的地址 component:HomeView }//配置的页面组件
  3. $route current routing information
  • name name
  • ⭐params routing parameters
  • path path
  • fullPath full path
  • ⭐query query parameters
  • hash hash
  1. programming jump
    01 .push(“/”) jump and add a history record
    02 .replace(“/”) jump replace (leave current history record)
    03 back() return .forward() go forward
    04 .go( -1) Go back one step
    05 .go(1) go one step forward
  2. Three steps to create a route ⭐⭐⭐ (refer to the picture below)
    01 Create a new file ⭐
    02 Configure a registered route ⭐
    03 Add a link ⭐
    insert image description here

Supongo que te gusta

Origin blog.csdn.net/m0_55734030/article/details/127272393
Recomendado
Clasificación