接着上一个工程写带有参数请求的路由跳转
一、
1.主页面 Main.vue 传递参数
<el-menu-item index="1-1">
<!--插入的地方-->
<router-link :to="{name:'UserProfile',params:{ id:1,name:'swk'}}">个人信息</router-link>
</el-menu-item>
<el-menu-item index="1-2">
<!--插入的地方-->
<router-link to="/user/list">用户列表</router-link>
</el-menu-item>
name:传递的组件名
params:传递参数
改成了:to ,即将这一属性绑定成对象
2.路由配置 index.js 里
children:[
{
path:'/user/profile/:id/:name',
name:'UserProfile',
component:Profile
},
{
path: '/user/list',
component: List
}
]
添加name 与上面组件名一致
/:id 添加参数占位符
3.在组件页 Profile.vue 中