3.21

81 阅读1分钟

query传参 和 动态路由params传参

{ path:"/Childa/:id",/* 后面加了:id是动态路由 */

name:"Childa",

component: ()=> import('../views/ChildA.vue'),

props:true }

在app页面中

router-link to="/Childa/1">ChildA</rout er-link>

{ path:"/ChildB",

name:"ChildB",

component: ()=> import('../views/ChildB.vue'), /* 局部路由钩子,因为参数或者动态路由,在同一个路由下不会触发 */ beforeEnter:(to,from,next)=>{

console.log(to);

console.log(from);

next() },

在app中

<router -link to="/ChildB?name=a">ChildB</router -link>