- route和routes的区别
//$router : 是路由操作对象,只写对象
//$route : 路由信息对象,只读对象
-
params
这是路由传参的一种方式,使用这种方式传参会隐藏地址栏的参数,
使用时不能用path来定义,需要使用到name//传参 this.router.push({ name:"good", params:{ id:"1111", name:"hello" } }); //路由 { path:/good/:id, name:"good", component:()=>import('@/view/good') } //接收参数 this.id = this.route.params.id; this.name = this.route.params.name; console.log('hello',this.route.params)
最终会得出一个对象
hello{id:"1111",name:"hello"}