vue-页面交互-传参-ths.$router.push

详细见 :this.$router.push() 传递参数的两种方法

前提条件:当我们使用  “动态路由的时候” 。动态路由

关键词:接收不到参数  ths.$router.push  params  query

 

params  传递参数

由于动态路由是使用params传值的。所以在 this.$router.push() 方法中path不能和params一起使用,否则params将无效。需要用name来指定页面。

 this.$router.push({
        name: 'new',
        params: {
          questionInfo: row
        }
 })

// 在目标页面通过this.$route.params获取参数
// 获取参数:
console.log(this.$route.params)

query传递参数

 this.$router.push({
        // name和path两种方式都可以,
        // name: 'new',
        path: 'new',
        query: {
          questionInfo: row
        }
 })

// 在目标页面通过this.$route.query获取参数
// 获取参数:
console.log(this.$route.query)

 


版权声明:本文为fxinn原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。