InAppBroswer: Uncaught SyntaxError: Block-scoped declarations .. not yet supported when loading js on Android App. outside strict mode

InAppBroswer: Uncaught SyntaxError: Block-scoped declarations .. not yet supported when loading js on Android App. outside strict mode

我遇到错误

未捕获的语法错误:块范围声明(let、const、函数、class)在严格模式之外尚不支持

当html头部添加如下js时,

;
;frappe.socket = {
   open_tasks: {},
   open_docs: [],
   emit_queue: [],
   ...
   doc_open: function(doctype, docname) {
       "use strict";
       if (!frappe.socket.last_doc || (frappe.socket.last_doc[0] != doctype && frappe.socket.last_doc[0] != docname)) {
           frappe.socket.socket.emit('doc_open', doctype, docname);
       }
       frappe.socket.last_doc = [doctype, docname];
   },
   ...
}

注意我添加了"use strict";基于现有的计算器线程。我仍然收到错误。 chrome 调试器指向以下行。

     frappe.socket.last_doc = [doctype, docname];

浏览器是一个 cordova 应用程序,运行 在 Android Studio Emulator 中。我认为它正在使用 InAppBrowser。 这个错误后剩下的js加载失败。我不确定哪个代码需要严格模式。

相同的代码在 chrome、Edge、FF 中没有 "use strict" 时运行良好。

发现问题:尽管 Google Chrome 开发人员 Window 显示了这一行,但该行是缩小的 JS 行中的第一条语句。

在查看完整的 Minified JS 行时, 我后来发现问题在另一行,

frappe.socket.file_watcher.on('reload_css', function(filename) { 
    let abs_file_path = "assets/" + filename; 

在此函数的开头添加“use strict”解决了这个问题。–