-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
30 lines (26 loc) · 1.04 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
// route-level code splitting
const createListView = id => () => import('../views/CreateListView').then(m => m.default(id))
const ItemView = () => import('../views/ItemView.vue')
const UserView = () => import('../views/UserView.vue')
const IndexView = () => import('../views/index.vue')
export function createRouter() {
return new Router({
mode: 'history',
fallback: false,
scrollBehavior: () => ({ y: 0 }),
routes: [
{ path: '/top/:page(\\d+)?', component: createListView('top') },
{ path: '/new/:page(\\d+)?', component: createListView('new') },
{ path: '/show/:page(\\d+)?', component: createListView('show') },
{ path: '/ask/:page(\\d+)?', component: createListView('ask') },
{ path: '/job/:page(\\d+)?', component: createListView('job') },
{ path: '/item/:id', component: ItemView },
{ path: '/user/:id', component: UserView },
{ path: '/', redirect: '/top' },
{ path: '/index', component: IndexView }
]
})
}