【问题标题】:JSLint throwing error when using console.log() [duplicate]使用 console.log() 时 JSLint 抛出错误 [重复]
【发布时间】:2017-04-10 13:25:20
【问题描述】:

我使用的文本编辑器是Brackets。当我尝试在任何 JS 文件中使用 console.log 时遇到错误消息。

1 - 创建/打开一个 JS 文件

2 - 输入 console.log('hello world');

3 - 保存文件

JSLint 问题:

error message in JSLint 'console' was used before it was defined.

【问题讨论】:

标签: javascript text-editor


【解决方案1】:

使用devel 选项:

true 是否应该预定义在开发中有用的浏览器全局变量,以及是否应该允许调试器语句和 TODO cmets。它添加了与该指令相同的全局变量:

/*global
alert, confirm, console, prompt
*/

确保在投入生产之前关闭此选项。

所以在你的脚本顶部添加这一行:

 /*jslint devel: true */

【讨论】:

  • 谢谢,我在文件顶部添加了/*jslint devel: true */
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-01
相关资源
最近更新 更多