|
@@ -1,22 +1,35 @@
|
|
|
|
|
+// import 语句 用于导入模块中的内容
|
|
|
|
|
+// 引入 vue
|
|
|
import Vue from 'vue'
|
|
import Vue from 'vue'
|
|
|
|
|
+// 引入 vue router
|
|
|
import VueRouter from 'vue-router'
|
|
import VueRouter from 'vue-router'
|
|
|
|
|
+// 引入 首页组件
|
|
|
|
|
+// ../ 表示返回上一级文件夹
|
|
|
|
|
+// 当前引入模式为同步引入(预加载) 一般用作与首页
|
|
|
import HomeView from '../views/HomeView.vue'
|
|
import HomeView from '../views/HomeView.vue'
|
|
|
|
|
|
|
|
Vue.use(VueRouter)
|
|
Vue.use(VueRouter)
|
|
|
-
|
|
|
|
|
|
|
+// 路由配置 里面为路由规则 每个路由规则都是一个对象 每一个对象也是一个页面
|
|
|
const routes = [
|
|
const routes = [
|
|
|
{
|
|
{
|
|
|
|
|
+ // path 路由路径
|
|
|
path: '/',
|
|
path: '/',
|
|
|
|
|
+ // name 路由名称
|
|
|
name: 'home',
|
|
name: 'home',
|
|
|
|
|
+ // component 路由组件 页面文件的地址
|
|
|
component: HomeView
|
|
component: HomeView
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
path: '/about',
|
|
path: '/about',
|
|
|
name: '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')
|
|
|
|
|
|
|
+ // 同样也表示引入页面组件 但是这里使用了异步引入(懒加载 需要显示页面的时候才加载)
|
|
|
|
|
+ component: () => import('../views/AboutView.vue')
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ // 路由路径小写
|
|
|
|
|
+ path: '/pageone',
|
|
|
|
|
+ name: 'pageone',
|
|
|
|
|
+ component: () => import('../views/PageOne.vue')
|
|
|
}
|
|
}
|
|
|
]
|
|
]
|
|
|
|
|
|