0

我正在尝试将 Firebase 与我的 Ember 应用程序一起使用。我安装了 Emberfire,但我的应用程序返回

未捕获的类型错误:无法读取未定义的属性“扩展”

因为它没有读取“FirebaseAdapter”

App.ApplicationAdapter = DS.FirebaseAdapter.extend({
    firebase: new Firebase('https://glowing-fire-number.firebaseio.com/')
});

我检查了是否在 Firebase 和 EmberFire 之前加载了 Ember 数据。这是我的脚本参考:

<!-- script references -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="http://maps.googleapis.com/maps/api/js?sensor=false&extension=.js&output=embed"></script>
    <script src="js/scripts.js"></script>

<script src="js/libs/jquery-1.11.2.min.js"></script> 
<script src="js/libs/handlebars-v1.3.0.js"></script>
<script src="js/libs/ember.js"></script>
<script src="js/libs/moment.js"></script>
<script src="http://builds.emberjs.com/tags/v1.0.0-beta.12/ember-data.js"></script>

<script src="js/app.js"></script>
<script src="vendor/list-view.js"></script>
<script src="js/controller.js"></script>

<script src="https://cdn.firebase.com/js/client/2.2.2/firebase.js"></script>
<script src="https://cdn.firebase.com/libs/emberfire/1.3.3/emberfire.min.js"></script>

还有我的 App.js

App = Ember.Application.create();

App.Router.map(function() {
  // put your routes here
  this.resource('stacks')
  this.resource('stack', {path: ':stack_id'}, function() {
        this.route('edit');
    }); 
    this.route('create');
  });


App.IndexRoute = Ember.Route.extend({
  beforeModel: function() {
    this.transitionTo('stacks');
  }
});

App.StacksRoute = Ember.Route.extend({
    model: function() {
        return this.store.findAll('stack');
    }
});

App.StackRoute = Ember.Route.extend({
    model: function(params) {
        return stacks.findBy('id', params.stack_id);
    }
});

Ember.Handlebars.helper('format-date', function(date) {
    return moment(date).fromNow();
});


App.CreateRoute = Ember.Route.extend({

});


//EmberFire stuff

App.ApplicationAdapter = DS.FirebaseAdapter.extend({
    firebase: new Firebase('https://glowing-fire-2514.firebaseio.com/')
});

App.Stack = DS.Model.extend({
  title: DS.attr('string'),
  location: DS.attr('string'),
  date: DS.attr('number'),
  details: DS.attr('string')
});

任何想法?我感谢您的帮助!

4

1 回答 1

4

app.js在包含 EmberFire 之后,您似乎需要包含。之后您的路由器中还缺少一个分号,this.resource('stacks')但我认为这不是导致错误的原因。

我们刚刚发布了一些更新,使将 EmberFire 用作 ember-cli 插件变得更加容易,我建议您检查一下。详细信息在这里:https ://www.firebase.com/blog/2015-03-09-new-emberfire-features.html

于 2015-03-10T16:11:30.670 回答