1、找到index.html。

vue前端执行过程

 

 

2、找到main.js

vue前端执行过程

 

 

3、挂载了router,然后去找router下的index.js

vue前端执行过程

 

 

 

index.js中,指定了路由。如:

path: '/index',就会根据 import Index from '@/components/Index' 去components下找Index组件

4.根据index.js中挂载的组件路径(如:path: '/index',),去找相应的组件。然后在App.vue显示。

vue前端执行过程

 

 

 

<router-link to="/index">首页</router-link>,根据路由做了链接,点击首页,就会跳到/index路径下

5.输入命令npm run dev,启动前端vue。

在浏览器地址栏输入:http://127.0.0.1:8080/index

注意:在index.js中的routes列表之后,加上 mode: 'history',否则路径应该是:http://127.0.0.1:8080/#/index

vue前端执行过程

 

相关文章:

  • 2021-09-18
  • 2021-12-18
  • 2022-01-03
  • 2021-08-09
  • 2021-11-12
猜你喜欢
  • 2022-01-10
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2021-09-04
  • 2021-06-30
  • 2022-12-23
相关资源
相似解决方案