vue-router 设置"path:'/'"无效

374 阅读1分钟

解决Vue配置路由不生效,自动跳转到首页_vue路由不起作用-CSDN博客

vue路由跳转默认为hash模式,需要在访问路径下添加#再加路由的path值。 解决方案:添加 mode:"history"

const router = new VueRouter({
  mode:'history',
  routes: [
    {
      path:"/",
      component:SuperMap,
    },
    {
      path: "/LeafletMap",
      component: LeafletMap,
    },
  ],
});