使用router-link传参:

第一种:

路径:http://localhost:8080/goodListP?id=2

router-link跳转页面传递参数及页面刷新方法

 

 

 

 跳转的页面获取参数:

 this.$route.query.id

router-link跳转页面传递参数及页面刷新方法

 

 

 

第二种:

路径:http://localhost:8080/goodListP/2

router-link跳转页面传递参数及页面刷新方法

 

 路由配置:

router-link跳转页面传递参数及页面刷新方法

 

 

 

 跳转的页面获取参数:

this.$route.params.id;

router-link跳转页面传递参数及页面刷新方法

 

 

问题:使用router-link跳转到页面时,页面要F5刷新一下才能获取到数据

解决方法如下:

第一种:

router-link跳转页面传递参数及页面刷新方法

 

 加上一个点击事件进行刷新页面

@click.native:事件后面要添加.native,不然添加的事件不起作用,具体原因应该是router-link为了阻止a标签的默认跳转事件

 

 

 router-link跳转页面传递参数及页面刷新方法

 

 

 

第二种:

不给router-link添加点击事件,在跳转到的页面中加上以下代码:

router-link跳转页面传递参数及页面刷新方法

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-01
  • 2022-12-23
  • 2022-12-23
  • 2021-10-18
  • 2021-05-11
  • 2022-12-23
猜你喜欢
  • 2022-01-16
  • 2021-11-28
  • 2021-11-20
  • 2021-10-13
  • 2021-05-20
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案