首页 > 解决方案 > 当我尝试在 Web 应用程序(Angular8)中继续进行活动时,为什么会在边缘和 Chrome 浏览器中出现“此页面没有响应”警告

问题描述

页面无响应问题

出现此错误后,我无法在该页面中进行任何活动,我需要关闭选项卡并重新打开另一个

Iam using a code to navigate to an array list (Next and Previous) using array indexing
Eg:
 NextClicked(){
        this.spinner.show('priority');
        let CurrentArray : any;
        this.buttonClicked = true
        this.bindStaff = false;
        this.NextClickCalled =true;
        console.log("======Next Clicked=====")
        let CurrentArrayElement = this.modelProject.ID
        console.log(CurrentArrayElement)
        CurrentArray = JSON.parse(localStorage.getItem('CurrentProjectPageRecords'));
        console.log(CurrentArray);
        let CurrIndex =  CurrentArray.findIndex(x => x.ID === this.modelProject.ID);

CurrIndex = CurrIndex+1

let NextID = CurrentArray[CurrIndex].ID

 this.router.navigate(['/projects/' + NextID +'/edit/'+this.projectType]);

}

Next 是从数组中获取下一个元素,Previous 是导航到上一个元素。继续使用这个会产生问题。如果我单击下一步 5 次并单击上一个页面卡在那里并显示上述浏览器警告

PreviousClicked(){
        this.spinner.show('priority');
        let CurrentArray : any;
        this.buttonClicked = true
        this.bindStaff = false;
        this.NextClickCalled =true;
        console.log("======Previous Clicked=====")
        let CurrentArrayElement = this.modelProject.ID
        console.log(CurrentArrayElement)
        CurrentArray = JSON.parse(localStorage.getItem('CurrentProjectPageRecords'));
        console.log(CurrentArray);
        let CurrIndex =  CurrentArray.findIndex(x => x.ID === this.modelProject.ID);

CurrIndex = CurrIndex-1

let NextID = CurrentArray[CurrIndex].ID

 this.router.navigate(['/projects/' + NextID +'/edit/'+this.projectType]);

}

不知道这是确切的问题,但我通过连续执行此活动得到警告

在此处查看 API

标签: javascripttypescriptgoogle-chromeangular8microsoft-edge

解决方案


为角度启用延迟加载解决了我的问题

谈论 Angular 和 CLI 确保启用延迟加载和延迟加载您的路由,这样初始有效负载会随着您的应用程序变得越来越复杂和功能越来越多而保持较小。由于生成的捆绑包是经过哈希处理的,因此由于前面部分的缓存标头,它们被正确缓存。

检查以下链接以获取有关延迟加载的更多详细信息

在此处输入链接描述


推荐阅读