Chrome 开发工具的页面导航中未发布 Angular 组件
我创建了新的 Angular 11 项目,然后添加了两个页面,其中只有一个 div 覆盖整个页面,如下所示:
// pour page
// component.html
<div style="width: 100vw; height: 100vh; background: cyan;" (click)="onClick()"></div>
// component.ts
@Component({
selector: 'app-pour-page',
templateUrl: './pour-page.component.html',
styleUrls: ['./pour-page.component.scss']
})
export class PourPageComponent implements OnInit {
constructor(private router: Router) { }
ngOnInit(): void {
}
onClick() {
this.router.navigateByUrl('selector');
}
}
// 选择器页面
// component.html
<div style="width: 100vw; height: 100vh; background: yellow;" (click)="onClick()"></div>
// component.ts
@Component({
selector: 'app-selector',
templateUrl: './selector.component.html',
styleUrls: ['./selector.component.scss']
})
export class SelectorComponent implements OnInit {
constructor(private router: Router) { }
ngOnInit(): void {
}
onClick() {
this.router.navigateByUrl('pour-page');
}
}
我尝试在 chrome 开发工具上检查内存快照,但它在检查器模式下显示不同的结果,并且非检查员模式。
正如您在上面的屏幕截图中看到的,在检查器模式(启用了触摸)下,它是在非检查器模式下显示内存泄漏。
这是检查器模式下的已知错误吗?我实在想不通到底出了什么问题。
I created fresh Angular 11 project and then added two pages with only one div covering the whole page as followings:
// pour page
// component.html
<div style="width: 100vw; height: 100vh; background: cyan;" (click)="onClick()"></div>
// component.ts
@Component({
selector: 'app-pour-page',
templateUrl: './pour-page.component.html',
styleUrls: ['./pour-page.component.scss']
})
export class PourPageComponent implements OnInit {
constructor(private router: Router) { }
ngOnInit(): void {
}
onClick() {
this.router.navigateByUrl('selector');
}
}
// selector page
// component.html
<div style="width: 100vw; height: 100vh; background: yellow;" (click)="onClick()"></div>
// component.ts
@Component({
selector: 'app-selector',
templateUrl: './selector.component.html',
styleUrls: ['./selector.component.scss']
})
export class SelectorComponent implements OnInit {
constructor(private router: Router) { }
ngOnInit(): void {
}
onClick() {
this.router.navigateByUrl('pour-page');
}
}
I tried to check memory snapshot on chrome dev tool but it is showing different results in inspector mode and non-inspector mode.
As you can see in above screenshots, in inspector mode(which has touch enabled), it is showing memory leaks while it is not in non-inspector mode.
Is this known bug in inspector mode? I really couldn't figure out what's wrong with it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论