vue中跳转的方法

1.router-link 跳转的方法

 <router-link :to='{path:"/CommentList",query:{id:this.$route.query.goodsid}}'> 
       <div class="right">
            <span>查看全部</span>
            <img src="../assets/image/flowerdetail_rightarrow.png" alt="">
        </div>
 </router-link>

2.点击方法跳转

this.$router.push({name: '/order/page1',params:{ id:'1'}});
this.$router.push({path: ''/order/index''});
this.$router.push({path: '/order/page1',query:{ id:'2'}});
   this.$router.push({ name: 'flowerpaysuccess', params: { orderId: '321'} })
 
  接收页面
 created(){
        this.id=this.$route.params.orderId;
        console.log(this.id)
    }
 

  

  

3.有时候跳转时需要传递一个数组,数组中带有多个参数,简便方法如下
如下的work数组中传递多个参数 id title img等等多个参数时

<router-link tag="aa" :to="{path:'/目标路径',query:{arry:work}}">

export default{
   data(){
       return{
           work:[ ],
       }
   }
}


在跳转到的页面中用 created()接收
created(){
    this.work=this.$route.query.arry;
}

  

posted @ 2019-12-16 14:00  四月和秋天  阅读(1398)  评论(0编辑  收藏  举报