我想隐藏course-report
组件上的页脚。如果我将下面的代码用于其他组件,例如/login
这有效,但是当我将此代码与 id route 一起使用时,这不起作用。如何解决这个问题?
router.events.forEach((event) = > {
if (event instanceof NavigationStart) {
if (event['url'] == 'coursereport/:id') {
this.showFoot = false;
} else {
// console.log("NU")
this.showFoot = true;
}
}
});
您可能应该检查字符串是否包含值而不是等同于它,并省略:id
:
router.events.forEach((event) => {
if (event instanceof NavigationStart) {
if (event['url'].includes('coursereport/') {
...
} else {
...
}
}
});