前言
之前,查了其他博客,總結(jié)一篇,發(fā)現(xiàn)貌似不對(duì)??,因此又查了一遍好不容易寫了出來(lái)。
1.query傳參
一種是,這樣滴。
// 跳轉(zhuǎn)
this.$router.query.push(name:'useredit',query:{id:scope.row.id});
<router-link :to="{name:'useredit',query:{id:scope.row.id}}" >編輯</router-link>
跳轉(zhuǎn)之后,路由路徑是這樣滴,添加了參數(shù)。
http://localhost:8080/useredit?id=8
在router中的index.js對(duì)應(yīng)的路由路徑,可以不用修改,用原路徑就可以。
// 注冊(cè)
{
path: "/register",
name: "register",
component: () => import("@/views/Login/RegiSter.vue")
},
this.$routr.query.id 拿到值
2.parms傳參
// 跳轉(zhuǎn)
this.$router.push(path:path:'/useredit/'+scope.row.id);
<router-link :to="{path:'/useredit/'+scope.row.id}" >編輯</router-link>
跳轉(zhuǎn)之后,頁(yè)面路徑變?yōu)?/p>
http://localhost:8080/useredit/8
在routet 的index.js文件需要更改路由路徑。
{
path:"/useredit/:id",
name:"useredit",
component: () => import ("@/views/User/UserEdit.vue")
},
this.$routr.params.id 拿到值
?總結(jié)
其實(shí),按照RusultFull來(lái)看,params傳參會(huì)好一點(diǎn)。文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-511822.html
反正,我沒(méi)覺(jué)得,那個(gè)會(huì)隱藏路徑。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-511822.html
到了這里,關(guān)于vue路由傳參的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!