简体   繁体   English

SyntaxError:'with'语句在严格模式下无效

[英]SyntaxError: 'with' statements are not valid in strict mode

I'm getting this error in safari console when I try to do anything from a breakpoint. 当我尝试从断点处做任何事情时,我在safari控制台中收到此错误。 Bug report here: https://bugs.webkit.org/show_bug.cgi?id=83267 Bug报告: https//bugs.webkit.org/show_bug.cgi?id = 83267

Does anyone have a workaround? 有没有人有解决方法? For reasons that I am assuming are related to this javascript has ceased to run on my site in safari. 由于我假设的原因与此相关,javascript已停止在我的网站上运行safari。

edit: the bug report also contains repro steps. 编辑:错误报告还包含repro步骤。

another edit: I'm not using a "with" statement. 另一个编辑:我没有使用“with”语句。 This is a bug from the safari console. 这是safari控制台的一个错误。

The with(obj) {} statement is deprecated, and as such, is not valid in strict mode. 不推荐使用with(obj) {}语句,因此在严格模式下无效。

To solve this, either disable strict mode, or stop using with statements! 要解决此问题,请禁用严格模式,或停止使用with语句!

Strict mode in ECMAScript 5 bans eg. ECMAScript 5中的严格模式禁止例如。 with statement. with声明。 You have two choices: 你有两个选择:

  • disable strict mode (remove "strict mode"; line from the file / function), or 禁用严格模式(删除"strict mode";文件/函数中的行),或
  • (preferred) avoid using with statements - they are harmful and totally unreadable. (首选)避免使用with语句-他们是有害的,完全不可读。

More on strict mode from John Resig: ECMAScript 5 Strict Mode, JSON, and More . 有关John Resig严格模式的更多信息: ECMAScript 5 Strict Mode,JSON等

You can read in the article, that strict mode: 你可以在文章中看到那种严格模式:

  • makes you unable to delete variable (like in delete foo; ), 使你无法delete变量(如delete foo; ),
  • limits usage of eval , 限制使用eval
  • adds some limitations to functions (eg. accessing caller and callee ), 为函数添加一些限制(例如访问callercallee ),
  • removes with statements, 除去with陈述,

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

相关问题 如何解决 HTMLUnit 中的“JavaScriptException value = SyntaxError: with statements not allowed in strict mode” - How to solve "JavaScriptException value = SyntaxError: with statements not allowed in strict mode" in HTMLUnit 严格模式下函数的SyntaxError - SyntaxError for functions in strict mode 语法错误:在严格模式下使用 const - SyntaxError: Use of const in strict mode 未捕获的语法错误:意外的严格模式保留字 - Uncaught SyntaxError: Unexpected strict mode reserved word Reactjs - SyntaxError: Octal literals are not allowed in strict mode - Reactjs - SyntaxError: Octal literals are not allowed in strict mode const os = require('os')SyntaxError:在严格模式下使用const - const os = require('os') SyntaxError: Use of const in strict mode 未捕获的 SyntaxError:严格模式代码可能不包含 with 语句 - Uncaught SyntaxError: Strict mode code may not include a with statement Visual Studio 任务运行程序“语法错误:在严格模式下使用 const。” - Visual Studio Task Runner "SyntaxError: Use of const in strict mode." SyntaxError:严格模式不允许在词法嵌套语句中使用函数声明 - SyntaxError: Strict mode does not allow function declarations in a lexically nested statement 未捕获的语法错误:意外的严格模式保留字 Vue.js - Uncaught SyntaxError: Unexpected strict mode reserved word Vue.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM