vue 路由(router)导入两种方式

第一种:

import Home from '../views/Home.vue'

Vue.use(VueRouter)

  const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  }
]

第二种:

注意箭头 ()=> 一定要有的!

import Home from '../views/Home.vue'

Vue.use(VueRouter)

  const routes = [
  {
    path: '/about',
    name: 'About',
    component: () => import('../views/About.vue')
  }
]

重定向:

import Home from '../views/Home.vue'

Vue.use(VueRouter)

  const routes = [
    {
      path: '/',
      redirect: 'login'
    }
]
Logo

前往低代码交流专区

更多推荐