美文网首页
2020-12-16 this.$router.push()后t

2020-12-16 this.$router.push()后t

作者: 追寻1989 | 来源:发表于2020-12-16 20:36 被阅读0次

由于动态路由也是传递params的,所以在 this.$router.push() 方法中path不能和params一起使用,否则params将无效。

需要用name来指定页面。并通过路由配置的name属性访问
例如:
通过name获取页面,传递params:

   this.$router.push({
        name: "ProductList",
        params: { type: "2" },
   });

在name为ProductList的目标页面通过this.$route.params获取参数:

  created() {
    this.tableFrom.type = this.$route.params.type || "0";
  },

相关文章

网友评论

      本文标题:2020-12-16 this.$router.push()后t

      本文链接:https://www.haomeiwen.com/subject/ftmogktx.html