zoukankan      html  css  js  c++  java
  • this.$router.push 传参

    index页面
    1.params
    this.$router.push()方法中path不能与params同用,否则param会失效,所以用name来指定页面,params来传递数据内容。

    <template> <img src="../../static/images/indexTermianal/teacher.png" alt="" @click ="go()" > </template> <script> methods:{ go:function(){ this.$router.push({ name:'indext', params:{ userId:1 } }) } } </script>

    在目标页面通过this.$route.params获取参数:
      <p>{{this.$route.params.userId}}</p>
     
    2.query
    页面通过path和query传递参数,该实例中row为某行表格数据
    methods:{
    go:function(){
    this.$router.push({
    path:'/indext',
    query:{
    userId:1
    }
    })
    }
    },
    目标页面this.$route.query.userId获取数据
    <p>{{this.$route.query.userId}}</p>
  • 相关阅读:
    自我介绍
    秋季学期总结
    第七周编程总结
    第六周作业
    第五周编程总结
    第四周编程总结
    第三周作业
    第二周作业
    抓老鼠啊~亏了还是赚了
    币值转换
  • 原文地址:https://www.cnblogs.com/rxfn/p/10717187.html
Copyright © 2011-2022 走看看