使用祕鑰登入Linux
阿新 • • 發佈:2022-05-08
params
1.配置路由,宣告接收params引數
export default new VueRouter({ routes: [ { path: "/about", component: RouteAbout, }, { path: "/home", component: RouteHome, children: [ { path: "/home/news", component: RouteNews, }, {
name:"yyy" path:"/home/message", component: RouteMessage, children: [{ path: "/home/message/detail/:id/:title", //使用佔位符宣告接收params引數
component: RouteDetail }], }, ], }, ],{{}} });
2.傳遞引數
<router-link :to="`/home/message/detail/${p.id}/${p.title}`">{{p.title}}</router-link>
or
<router-link :to="{ name:'yyy', params: { id: p.id, title: p.title, }, }" ></router-link>
注:路由帶params引數時,若使用to的物件寫法,則不能使用path配置項,必須使用name
3.接收引數
$route.params.id
$route.params.title