Vue 导航守卫用法 动态路由 路由懒加载






import Vue from 'vue'
import Router from 'vue-router'
const GoodsList = () => import(/* webpackChunkName: "group-main" */'@/views/GoodsList')

Vue.use(Router)

const routes = [
  {
    path: '/goods/:goodsId/user/:name',
    name: 'GoodsList',
    component: GoodsList,
    beforeEnter: (to, from, next) => {
      next()
    }
  }
]

let router = new Router({
  routes: routes
})

router.beforeEach((from, to, next) => {
  // console.log(from)
  // console.log(to)
  next()
})
router.afterEach((from, to) => {
  // console.log(from)
  // console.log(to)
})

export default router

 

你可能感兴趣的:(vue,Vue,导航守卫)