问题描述
我想要实现的是在某个时刻禁用和重新启用后退按钮。 我使用以下方法禁用后退按钮:
disableBackButton() {
history.pushState(null,null,location.href);
this.locationStrategy.onPopState(() => {
history.pushState(null,location.href);
})
}
但是,我不知道如何实现“重新启用”后退按钮的功能。
解决方法
好的!在按钮 html 中取 [disabled]="disabled==0"
并在 ts 文件中定义 disabled:any 属性...然后在里面简单地使用
this.disabled = 0; // when you want it to be disabled...
this.disabled=1; // when you want it to be enabled...
在您的函数中。