天天看點

ES6配置的路由對比ES5配置的路由

// 子產品路由(基于主入口布局頁面)
export const moduleRoutes = {
    path: '/',
    component: () => import('@/views/main'),
    name: 'main',
    redirect: {name: 'home'},
    meta: {title: '主入口布局'},
    children: [
        {path: '/home', component: () => import('@/views/modules/home'), name: 'home', meta: {title: '首頁', isTab: true}}
    ]
}      
import Vue from 'vue'
import VueRouter from 'vue-router'
import only from 'only .vue'
import two from 'two.vue'
import three from 'three.vue'

Vue.use(VueRouter)//使用路由元件

export default new VueRouter ({
    routes: [
        {
            path: '/only ',
            component: only //跳轉到one元件下
        },
        {
            path: '/tow',
            component: tow
        },
        {
            path: '/three',
            component: three
        },
        {
            path: '/',//重定向路由,即預設路由
            redirect: '/only '
        }
    ]
})