简体   繁体   English

InAppBroswer:未捕获的SyntaxError:在Android App上加载js时,尚不支持块范围的声明.. 外部严格模式

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

I am getting error 我遇到错误

Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode 未捕获的SyntaxError:严格模式之外尚不支持块范围的声明(let,const,函数,类)

when the following js is added to the html head, 将以下js添加到html头时,

;
;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];
   },
   ...
}

Note I added "use strict"; 注意我添加了“ use strict”; based on existing stackoverflow threads. 基于现有的stackoverflow线程。 I am still getting the error. 我仍然遇到错误。 The chrome debugger points at the below line. chrome调试器指向以下行。

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

The browser is a cordova app, running in Android Studio Emulator. 该浏览器是可在Android Studio模拟器中运行的cordova应用。 I think it is using InAppBrowser. 我认为它正在使用InAppBrowser。 The remaining js fails to load after this error. 此错误后,剩余的js无法加载。 I am not sure which code needs strict mode. 我不确定哪个代码需要严格模式。

The same code runs fine without "use strict" in chrome, Edge, FF. 相同的代码可以正常运行,而无需在chrome,Edge,FF中“严格使用”。

Found the issue: Even though the Google Chrome Developer Window was showing this line, This line was the first statement in the minified JS line. 发现了问题:即使Google Chrome开发者窗口显示了这一行,该行还是缩小的JS行中的第一条语句。

On looking at the complete Minified JS line, I found the issue is in another line later, 在查看完整的Minified JS行时,我发现问题在另一行中,

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

Adding "use strict at the start of this function fixed the issue. – 在此功能开始时添加“ use strict”可解决此问题。–

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Typescript和Uncaught SyntaxError:在严格模式之外尚不支持块范围的声明(let,const,function,class) - Typescript and Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode AngularJS:严格模式之外尚不支持块范围的声明(let,const,函数,类) - AngularJS: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode Angular:在Chrome中严格模式之外尚不支持块范围声明 - Angular: Block-scoped declarations not yet supported outside strict mode in Chrome 在Kriasoft React样板中,严格作用域之外的严格作用域尚不支持const函数类的块范围声明 - Block-scoped declaration let const function class not yet supported outside strict mode in kriasoft react boiler plate (教程)脚本由于SyntaxError无法运行:范围限定的声明 - (Tutorial) Script does not run due SyntaxError: Block-scoped declarations Visual Studio代码,块范围的声明 - Visual Studio Code, Block-scoped declarations 块范围的声明…TypeScript和Asp.net MVC 5 - Block-scoped declarations … TypeScript and Asp.net MVC 5 为什么在 JavaScript 中为块范围变量声明选择名称“let”? - Why was the name 'let' chosen for block-scoped variable declarations in JavaScript? 如何修复nodemon“块范围声明...”错误? - How to fix nodemon "block-scoped declarations..." error? 未捕获的语法错误:意外的严格模式保留字 Vue.js - Uncaught SyntaxError: Unexpected strict mode reserved word Vue.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM