我正在使用直接Web Remoting (DWR) JavaScript库文件,只在Safari(桌面和iPad)中得到一个错误

它说

超过最大调用堆栈大小。

这个错误到底是什么意思,它是否完全停止处理?

Safari浏览器也有任何修复(实际上是在iPad Safari上,它说

JS:执行超时

我认为这是相同的调用堆栈问题)


当前回答

在我的例子中,在app。module中。ts,我得到这个错误,因为我在imports和entryComponents中声明了组件。

Example:

import { MyComponent } from '....';

@NgModule({
  declarations: [
    MyComponent 
  ],
  imports: [
    MyComponent  -- > remove this from here!!!!
  ],
  providers: [],
  bootstrap: [AppComponent],
  entryComponents: [MyComponent]
})
export class AppModule { }

其他回答

如果您不小心导入/嵌入了相同的JavaScript文件两次,有时会出现这种情况,值得在检查器的资源选项卡中检查。

在我的例子中,我发送的是输入元素而不是它们的值:

$.post( '',{ registerName: $('#registerName') } )

而不是:

$.post( '',{ registerName: $('#registerName').val() } )

这冻结了我的Chrome标签到一个点,它甚至没有显示我的“等待/杀死”对话框,当页面变得无响应…

dtTable.dataTable({
    sDom: "<'row'<'col-sm-6'l><'col-sm-6'f>r>t<'row'<'col-sm-6'i><'col-sm-6'p>>",
    "processing": true,
    "serverSide": true,
    "order": [[6, "desc"]],
    "columnDefs": [
        {className: "text-right", "targets": [2, 3, 4, 5]}
    ],
    "ajax": {
        "url": "/dt",
        "data": function (d) {
            d.loanRef = loanRef;
        }
    },
    "fnRowCallback": function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
        var editButton = '';
        // The number of columns to display in the datatable
        var cols = 8;
        // Th row element's ID
        var id = aData[(cols - 1)];
    }
});

在上面的数据函数中,我使用了相同的名称d.loanRef = loanRef,但没有创建变量loanRef,因此递归地声明了自己。

解决方案:声明一个loanRef变量,或者更好的是,使用与d.loanRef不同的名称。

几乎每个答案都说这只能由无限循环引起。这是不正确的,否则您可以通过深度嵌套调用溢出堆栈(并不是说这是有效的,但它肯定是在可能的范围内)。如果你可以控制你的JavaScript虚拟机,你可以调整堆栈大小。例如:

节点——时= 2000

请参见:如何在Node.js中增加最大调用堆栈大小

在我的例子中,click事件在子元素上传播。所以,我不得不写以下内容:

e.stopPropagation ()

点击事件:

 $(document).on("click", ".remove-discount-button", function (e) {
           e.stopPropagation();
           //some code
        });
 $(document).on("click", ".current-code", function () {
     $('.remove-discount-button').trigger("click");
 });

下面是html代码:

 <div class="current-code">                                      
      <input type="submit" name="removediscountcouponcode" value="
title="Remove" class="remove-discount-button">
   </div>