【问题标题】:DS FixtureAdapter error Undefined for Ember JSDS FixtureAdapter 错误未为 Ember JS 定义
【发布时间】:2015-03-11 04:21:25
【问题描述】:

我不断收到 DS.FixtureAdapter Undefined 错误。我不确定如何解决此错误。我在 App.PersonAdapter = DS.FixtureAdapter.extend({});

这里是 app.js 代码。

App = Ember.Application.create();

App.Router.map(function() {
  // put your routes here

});



App.PersonAdapter = DS.FixtureAdapter.extend({});

App.Person = DS.Model.extend({
firstName: DS.attr(),
lastName: DS.attr(),
age: DS.attr()

});
App.IndexRoute = Ember.Route.extend({
  model: function() {
    return this.store.find('person');
  }
});
App.Person.FIXTURES = [
{
    id: 1,
    firstName: 'John',
    lastName: 'Doe',
    age: 39
},

{
    id: 2,
    firstName: 'Jane',
    lastName: 'Doe',
    age: 29
}
]

ember js 的 index.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Ember Starter Kit</title>
  <link rel="stylesheet" href="css/normalize.css">
  <link rel="stylesheet" href="css/style.css">
</head>
<body>
  <script type="text/x-handlebars">
    <h2>Welcome to Ember.js</h2>

    {{outlet}}
  </script>

  <script type="text/x-handlebars" id="index">

    <ul>
    {{#each item in model}}
      <li>{{item.firstName}} - {{item.lastName}} is of age {{item.age}}</li>
    {{/each}}
    </ul>
  </script>

  <script src="js/libs/jquery-1.10.2.js"></script>
  <script src="js/libs/ember-template-compiler-1.10.0.js"></script>
  <script src="js/libs/ember-1.10.0.debug.js"></script>
  <script src="js/libs/ember-data.js"></script>



  <script src="js/app.js"></script>
  <!-- to activate the test runner, add the "?test" query string parameter -->
  <script src="tests/runner.js"></script>
</body>
</html>

【问题讨论】:

    标签: html ember.js ember-data


    【解决方案1】:

    DS.FixtureAdapter 不属于ember.js 您需要包含ember-data.js,它仍处于测试阶段,需要从here 下载。

    工作示例here

    【讨论】:

    • 好吧,显然没有看到包含...否则,它没有理由不工作,就像我在工作示例中展示的那样
    • 在我提出问题之前,我将 ember-data.js 包含在我上面的代码中仍然无法正常工作我下载了测试版
    • 看来我用错了我会用你发的那个
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-03
    • 2015-05-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多