import VueRouter from 'vue-router' import Vue from 'vue' // 懒加载引入页面组件,es6语法 const Home = () => import('views/home/Index') const StatusIndex = () => import('views/home/Status') const VideoIndex = () => import('views/home/Video') const AudioIndex = () => import('views/home/Audio') const ImageIndex = () => import('views/home/Image') const ImagePage = () => import('views/home/ImagePage') const ArticleIndex = () => import('views/home/Article') const Search = () => import('views/home/Search') const VideoPage = () => import('views/home/VideoPage') const HomeIndex = () => import('views/user/Home') const FollowIndex = () => import('views/user/follow') const ProfileIndex = () => import('views/user/Profile') const CollectionIndex = () => import('views/user/Collection') const HistoryIndex = () => import('views/user/History') const PostList = () => import('views/post/PostList') const PostPublish = () => import('views/post/PostPublish') const PostAnalysis = () => import('views/post/PostAnalysis') // 使用安装路由插件 Vue.use(VueRouter) const routes = [ { path: '/', name: 'index', component: Home }, { path: '/status/:id', name: 'StatusIndex', component: StatusIndex }, { path: '/video', name: 'VideoIndex', component: VideoIndex }, { path: '/video/:id', name: 'VideoPage', component: VideoPage }, { path: '/audio', name: 'AudioIndex', component: AudioIndex }, { path: '/image', name: 'ImageIndex', component: ImageIndex }, { path: '/image/:id', name: 'ImagePage', component: ImagePage }, { path: '/article', name: 'ArticleIndex', component: ArticleIndex }, { path: '/search', name: 'search', component: Search }, { path: '/user/:id', name: 'HomeIndex', component: HomeIndex }, { path: '/user/:id/follow', name: 'FollowIndex', component: FollowIndex }, { path: '/u/profile', name: 'ProfileIndex', component: ProfileIndex }, { path: '/u/collection', name: 'CollectionIndex', component: CollectionIndex }, { path: '/u/history', name: 'HistoryIndex', component: HistoryIndex }, { path: '/user/post/list', name: 'PostList', component: PostList }, { path: '/user/post/publish', name: 'PostPublish', component: PostPublish }, { path: '/user/post/analysis', name: 'PostAnalysis', component: PostAnalysis }, { path: '*', name: '404', component: () => import('@/views/404.vue'), meta: { title: '404' } } ] // 创建路由对象 const router = new VueRouter({ mode: 'history', routes }) // 导出router export default router