Vue 路由传参与取值的两种方法

1.query 

query 相当于get,会在地址栏中显示传递的参数

传参

this.$router.push(
    {
      path: path,
      query: {
        data:data
      },
    }
  )

获取参数

this.$route.query

2.params

params 相当于post,params传参必须传递name,传递对象,可不写path

传参

this.$router.push(
    {
      path: path,
      name: 'alarm1',
      params: {data}
    }
  )

获取参数

this.$route.params
发布了111 篇原创文章 · 获赞 19 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/qq_34607371/article/details/102939841