router 配置按需加载对应的组件,配置active

 1 const routes = [
 2   {
 3     path: '/',
 4     component: App,
 5     children: [
 6       {path: '/index/:type', name: 'index', component: Index},
 7       {path: '/home', name: 'home', component: Home},
 8       {path: '/HomeUserInfo/:uid', name: 'homeUserInfo', component: HomeUserInfo},
 9       {path: '/article/:id', name: 'article', component: Article},
10       {path: '/addmsg', name: 'addMsg', component: AddMsg},
11       {path: '/search/:types', name: 'searchresult', component: SearchResult},
12       {path: '/login', name: 'login', component: Login},
13       {path: '/register', name: 'register', component: Register},
14       {path: '/modif', name: 'Modifi', component: Modifi},
15       {path: '/admin', name: 'Admin', component: Admin}
16     ]
17   }
18 ]
19 const router = new VueRouter({
20   routes: routes, // short for routes: routes
21   linkActiveClass: 'active',  // router-link的选中状态的class,也有一个默认的值
22   history: true
23 })

 

posted @ 2017-03-22 00:14  黄鹂  阅读(240)  评论(0编辑  收藏  举报