3.Vue中點選button跳轉至新的路由
阿新 • • 發佈:2018-12-14
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元件