vue项目中去除url中的/#,可以使用带参数

原路由文件

export default new Router({
  routes: [
    {
      path: '/',
      name: 'IndexPage',
      component: IndexPage
    }
  ]
})

修改后路由文件

export default new Router({
  base: '/dist/',//需要加上不然那访问路由是空白的
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'IndexPage',
      component: IndexPage
    }
  ]
})

修改内容添加 mode: ‘history’,

mode: 'history',
可以写入路由参数http://localhost:8080?id=0

用于首页登录验证跳转

你可能感兴趣的:(vue,url)