【问题标题】:jshint erros while including js in custom MEAN.IO package在自定义 MEAN.IO 包中包含 js 时出现 jshint 错误
【发布时间】:2015-07-06 09:56:53
【问题描述】:

我正在尝试包含一个我从头开始创建的 js 文件。这个 javascript 需要其他 js 文件,如 OpenLayers 和 jQuery(我也通过聚合它来导入)但是 jsHint 使我的项目失败,说明 $ 未定义或 ol 未定义。

【问题讨论】:

    标签: jquery openlayers jshint mean.io


    【解决方案1】:

    听起来你需要告诉 jshint 如何表现。在您的项目根目录中添加一个名为 .jshintrc 的文件,其中包含以下内容:

    {
      "jquery": true
    }
    

    这应该可以解决您的 $ 错误。您可以使用 predef 选项解决任何其他关于未定义全局变量的警告,如下所示:

    {
      "jquery": true,
      "predef": [
        "requirejs", "Backbone", "your_global_here"
      ]
    }
    

    您可以在 jshintrc 中添加大量其他选项:http://jshint.com/docs/options/

    【讨论】:

    • 嗨,先生,有没有办法让 jshint 看到这些变量而不是使用 predef?谢谢!
    • 我不确定你让 jshint “看到”这些变量是什么意思,你能详细说明一下吗?
    猜你喜欢
    • 2018-11-27
    • 1970-01-01
    • 2016-09-11
    • 2011-07-14
    • 1970-01-01
    • 2011-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多