1) 在router文件下的index.js中,添加相关路径

Vue:不同页面之间的传递参数(二)---query
routes: [
    {
      path: '/',
      name: 'Hello',
      component: HelloWorld
    },
    {
        path:"/paramsUrl",
        component:paramsUrl
    }
  ]
Vue:不同页面之间的传递参数(二)---query

2) 在HelloWorld组件中传递参数,这里用的是点击事件跳转

this.$router.push({path:"/paramsUrl",query:{name:'Tom',age:18,sex:'male'}})

在paramsUrl组件中可以在url中看到

http://localhost:8080/#/paramsUrl?name=Tom&age=18&sex=nan

获取参数方法

this.$route.query

注意:如果在router中有那么参数,只需要将第二步中path替换成name即可

相关文章:

  • 2021-06-09
  • 2022-12-23
  • 2021-07-27
  • 2021-10-05
  • 2021-12-04
  • 2021-08-14
  • 2021-10-21
  • 2022-12-23
猜你喜欢
  • 2021-06-25
  • 2022-12-23
  • 2021-07-05
  • 2021-12-17
  • 2022-12-23
相关资源
相似解决方案