要求描述

页面访问地址
首页:https://hello.haha.com/world
用户中心 :https://hello.haha.com/world/user

路由设置

路由配置js 设置 mode 为history ,这样会去掉#号 和正常的路由地址一样

export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/world', // 注意 路由的path 需要和页面的地址保持一致,即域名后的二级目录都得一样,否则会报错
      name: 'index',
      component: index
    },
    {
      path: '/world/user', 
      name: 'user',
      component: user
    },
    {
      path: '*',
      redirect: {name: 'index'}
    }
  ]
})

ngix服务器配置

vue官方文档推荐

vue history 路由模式打包发布到服务器设置

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2022-01-22
  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
  • 2021-12-02
猜你喜欢
  • 2022-12-23
  • 2021-12-25
  • 2021-12-31
  • 2022-12-23
  • 2021-08-21
  • 2021-04-08
相关资源
相似解决方案