业务
复用组件
进入详情页,使用props
将组件和路由解耦:加上 props: true
{
path: '/admin/ecs/:id',
name: 'ecs_detail',
meta: {activeMenu: '/admin/ecs'},
component: () => import('@/admin/ecs/detailPage'),
props: true
}
组件中使用:
export default {
props: ['id'],
methods: {
getId() {
if (this.id) {
this.ecs_id = this.id;
}
}
}
};
还有一种方式可获取路由参数 this.$route.params.id