1

应用程序

var App = Ember.Application.extend({
    LOG_ACTIVE_GENERATION: true,
    LOG_MODULE_RESOLVER: true,
    LOG_TRANSITIONS: true,
    LOG_TRANSITIONS_INTERNAL: true,
    LOG_VIEW_LOOKUPS: true,
    modulePrefix: 'appkit', // TODO: loaded via config
    Resolver: Resolver['default']
});


Ember.RSVP.configure('onerror', function(error) {
  // ensure unhandled promises raise awareness.
  // may result in false negatives, but visibility is more important
  if (error instanceof Error) {
    Ember.Logger.assert(false, error);
    Ember.Logger.error(error.stack);
   }    
});
export default App;

店铺

App.Store = DS.Store.extend({
    adapter: "DS.RESTAdapter"
});

模型

App.User = DS.Model.extend({
email: DS.attr('string'),
password: DS.attr('string')
});

控制器

var LoginController = Ember.Controller.extend({
actions: {
    login:function(){

        //var data = this.getProperties('email','password');
        console.log("Before Store");
        var store = this.get('store');
        var email = this.get('email');
        var password = this.get('password');
        console.log(":"+email+":"+password);
        var user = store.createRecord('user',{
            email: email,
            password: password
        });
        console.log("User"+user);
    }
}
});
export default LoginController;

我有一个登录视图,从那里触发登录操作。一旦触发该操作,我就会收到一条错误消息,指出无法读取 undefined 的属性“默认”

我试过把 App.User.createRecord 这给了我错误Cannot call method 'createRecord' of undefined

我正在使用 ember-appkit。我还检查了 ember-data 的版本(版本:1.0.0-beta.5+canary)我无法确定我哪里出错了。

4

0 回答 0