3.Vue中点击button跳转至新的路由

1.params传参:
this.$router.push({name:'parasetEdit',params:{pk_refinfo:'test',value:'test1'}});
目标页面接收参数:

this.$route.params.pk_refinfo

2.query传参:

this.$router.push({path:'/uapbd/paraset/edit',query:{pk_refinfo:'test',value:'test1'}});

目标页面接收参数:

this.$route.query.pk_refinfo
 

常用:params传参,注意传的路由的name 而不是path

步骤1:在template中定义click事件:
<div class="glyphicon glyphicon-plus-sign" title="点击我新增项目"
             @click="createnewproject"></div>

步骤2:在methods中定义createnewproject方法
methods:{
    createnewproject(){
        this.$router.push({ name:'newproject', params:{id:'2'}})
        }
}

步骤3:在index.js文件中定义路由
{
      path:'/newproject',
      name:'newproject',
      component:newproject
}

步骤4:在components中新建newproject组件


猜你喜欢

转载自blog.csdn.net/qq_37969201/article/details/84322595