vue-route中base配置的解释

如果整个单页应用服务在 /learn/ 下,然后 base 就应该设为 “/learn/”

// route.js
const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  }
]
const router = new VueRouter({
  mode: 'history', // history 和 hash 模式  hash模式下路由会多一个“#” history
  base: '/learn', // 配置单页应用的基路径 localhost:8080/learn/about 和 localhost:8080/about 访问是一样的
  routes
})
/about
/learn/about

你可能感兴趣的:(vue-route中base配置的解释)