一、原始方法
{
path: '/about/:id/:name',
component: About
}
页面拿参数 : this.$route.params.id
二、props(布尔值方法)
tips:此方法只能通过params
方式上行得通
{
path: '/about/:id/:name',
component: About,
props:true
}
页面拿参数 在页面 props:['id','name]
二、props(函数方法)
{
path: '/about/:id/:name',
component: About,
props($route){
id:$route.params.id,
name:$route.params.name,
}
解构写法
{
path: '/about/:id/:name',
component: About,
props({params:{id,name}}){//连续解构赋值
return {id,name}
}