本文介绍了Ember-CLI:修复“Ember”未被定义“?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用Ember-CLI并运行ember服务器时,我从JSLint中收到以下错误:

When using Ember-CLI and running ember server, I get the following error from JSLint:

[app_path]/filename.js: line 1, col 16, 'Ember' is not defined.

从ember添加导入Ember; 修正这个。

Adding import Ember from 'ember'; fixes this.

这是正式的方式去现在我所有的文件?文件没有提到这个变化。

Is this the official way to go now on all my files? The documentation does not mention this change yet.

推荐答案

编辑

来自Stephan Penner:

From Stephan Penner:

我们计划将越来越多的ember暴露为es6,有一天,
允许工具移除您没有使用的部分Ember 。
导致较小的版本。

We plan on exposing more and more of ember as es6, someday this will allow the tooling to remove parts of ember you are not using. Resulting in smaller builds.

仍然,直到那个日期,它可能会为您节省很多麻烦在 .jshintrc

Still, until that date it's probably going to save you a lot of hassle to put it in .jshintrc.

OUTDATED ANSWER

在您的 .jshintrc 文件(或 tests / .jshintrc )中,添加全局中的任何内容命名空间你不想在每个模块中定义到predef对象。例如:

In your .jshintrc file (ortests/.jshintrc), add anything in the global namespace you don't want to have to define in each module to the predef object. For example:

{
  "predef": {
    "document": true,
    "window": true,
    "SprintStatusENV": true,
    "Ember": true, // Added
    "$": true, // ADDED
    "Modernizr": true // ADDED
  },
  "browser" : true,
  "boss" : true,
  "curly": true,
  "debug": false,
  "devel": true,
  "eqeqeq": true,
  "evil": true,
  "forin": false,
  "immed": false,
  "laxbreak": false,
  "newcap": true,
  "noarg": true,
  "noempty": false,
  "nonew": false,
  "nomen": false,
  "onevar": false,
  "plusplus": false,
  "regexp": false,
  "undef": true,
  "sub": true,
  "strict": false,
  "white": false,
  "eqnull": true,
  "esnext": true,
  "unused": true
}

在这个例子中,我定义Ember(也可以定义Em),jQuery使用'$'和Modernizr。这将停止终端中出现的jshint错误消息。

In this example, I define Ember (could also define Em), jQuery using '$' and Modernizr. This will stop the jshint error messages appearing in the terminal.

这是根据:

这篇关于Ember-CLI:修复“Ember”未被定义“?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 15:11