解决vue-router跳转不起作用

router 这么写:

export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/homePage',
      name: 'HomePage',
      component: HomePage
    },
    {
      path: '/topUpPage',
      name: 'TopUpPage',
      component: TopUpPage
    }
  ]
})

a标签这么写:

充值

点击a标签后,地址栏变成:http://localhost:8088/topUpPage,但是显示不出来页面,意味着我这个配置不起作用。由于我直接地址栏访问http://localhost:8088/homePage,可以跳转到有homePage.vue的页面,也就是说我的router路径配置没有问题,因为另一个router起了作用。但这个就不行。

解决:

将a标签改为:

充值

 即去掉地址栏里的"/",就可以了。

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