Internet Explorer 11脚本错误指向错误的文件

问题描述 投票:0回答:1

我很难在Internet Explorer 11中找到那行错误的代码,因为控制台指向了错误的资源(指向HTML而不是JS代码)。我怎么可能找到真正的问题所在?

控制台错误

(SCRIPT1003 是 "预期的''"和 SCRIPT1028 将是 "预期的标识符、字符串或数字")

enter image description here

错误所指的代码行

第4行和第5行。

Line 4 and 5

第12行。

report-template line 12

internet-explorer-11 javascript-debugger ie11-developer-tools
1个回答
0
投票

把这个答案留给我自己的问题,这样别人可能也会被同样的问题绊倒。

如果任何脚本文件在初始页面加载后被异步加载,在控制台中报告的文件名将指向执行加载资源的文件。在我的案例中,我使用了JQuery的 $.getScript() 方法来处理这个任务。

  translationInitHandler.initialise(function() {
    store.commit('setTranslation', window.defaultTranslationHandler.getCatalogueTranslations());
    $.getScript('../src/app/report-template/warning.app.js');
    $.getScript('../src/app/report-template/list.app.js');
    $.getScript('../src/app/report-template/authorize.app.js');
    $.getScript('../src/app/report-template/edit-configure.app.js?3');
  }, false);

有趣的是,所提到的行和列指的是加载脚本中的正确位置。在我的案例中,我在Vue应用程序中包含了一个无效的属性(在IE11的视图中)。

window.createApp = new Vue({
  el: '#create-view',
  store, // triggers IE error
  data: {
    ...
  },
  ...
});
© www.soinside.com 2019 - 2024. All rights reserved.