javascript - 当我尝试在 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]);
}
不知道这是确切的问题,但我通过连续执行此活动得到警告
解决方案
为角度启用延迟加载解决了我的问题
谈论 Angular 和 CLI 确保启用延迟加载和延迟加载您的路由,这样初始有效负载会随着您的应用程序变得越来越复杂和功能越来越多而保持较小。由于生成的捆绑包是经过哈希处理的,因此由于前面部分的缓存标头,它们被正确缓存。
检查以下链接以获取有关延迟加载的更多详细信息
推荐阅读
- c# - RestSharp 方法抛出 System.Xml.XMlException "=" 是一个意外的标记。预期的标记是';'
- javascript - Phaser 3 创建圆形区域
- ios - 以每行 3 个单元格的布局将cornerRadius 添加到第一个和第三个 UICollectionViewCell
- powershell - 如何使用 powershell 安装 cuda(nvidia 驱动程序)静默模式?
- angular - 无法从 *ngFor 生成的带有对象类型输入的表单发送更改的数据
- c# - 相同的 LINQ 组元素
- python - 如何将excel表中的数据同时导入到关系表中
- c# - C# Socket 只能发送一次
- sqoop - sqoop从mysql导入数据,job没有启动
- asynchronous - 通过 join_all 的多个期货,每个期货都返回一个通过 Reqwest 获取的字符串