前端Vue 执行流程
Vue的执行流程
一般来说,当启动vue程序时,系统会先调用main.js文件
在main.js中,创建了一个新的vue对象并将其挂载到App.vue中id为app的html组件中
在App.js中,引入<router-view/>
标签来进行路由管理,系统会进入router文件夹中的index.js文件中来寻找路由
import VueRouter from 'vue-router' import HomeView from '../views/HomeView.vue' Vue.use(VueRouter) const routes = [ { //不加任何后缀的路由,localhost:8080/ path: '/', name: 'home', component: HomeView }, { //加后缀的路由,localhost:8080/about path: '/about', name: 'about', // route level code-splitting // this generates a separate chunk (about.[hash].js) for this route // which is lazy-loaded when the route is visited. component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue') } ] const router = new VueRouter({ mode: 'history', base: process.env.BASE_URL, routes }) export default router
然后系统会跟据不同的路由来展示不同的页面。
https://blog.csdn.net/Eric_fo/article/details/130339203
================================================
标签:about,vue,启动,流程,js,Vue,router,路由 From: https://www.cnblogs.com/emanlee/p/18008345