[英]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.