【问题标题】:routing error after updating emberjs更新 emberjs 后出现路由错误
【发布时间】:2013-09-04 07:53:24
【问题描述】:

我尝试将我的应用程序 emberjs 版本从 1.0.0 rc8 更新到 1.0.0,但出现路由错误。在我的应用程序路线中,我有这些代码:

OlapApp.ApplicationRoute = Ember.Route.extend({
    setupController: function (controller, model) {
        this.controllerFor('column').set('model', OlapApp.AxisModel.find());
       this.controllerFor('row').set('model', OlapApp.AxisModel.find());
   },
   renderTemplate: function (controller, context) {
      this._super(controller, context);
      this.render('application');
      this.render('column', {
        into: 'application',
        outlet: 'column',
        controller: 'column'
    });
    this.render('row', {
        into: 'application',
        outlet: 'row',
        controller: 'row'
    });
},
  dimenssionTree: function () {
    return OlapApp.MeModel.find();
}
});

并得到这个错误:

DEPRECATION: Action handlers contained in an `events` object are deprecated in favor of          putting them in an `actions` object (error on <OlapApp.ApplicationRoute:ember314>)
    at Object.triggerEvent (file:///F:/OLAP/app/lib/ember.js:30519:13)
    at trigger (file:///F:/OLAP/app/lib/ember.js:29641:16)
    at handlerEnteredOrUpdated (file:///F:/OLAP/app/lib/ember.js:29537:11)
    at file:///F:/OLAP/app/lib/ember.js:29512:9
    at eachHandler (file:///F:/OLAP/app/lib/ember.js:29559:9)
    at setupContexts (file:///F:/OLAP/app/lib/ember.js:29511:7)
    at finalizeTransition (file:///F:/OLAP/app/lib/ember.js:29835:7)
    at transitionSuccess (file:///F:/OLAP/app/lib/ember.js:29732:13)
    at invokeCallback (file:///F:/OLAP/app/lib/ember.js:8055:19) ember.js:394
 Error while loading route: TypeError {} ember.js:394

如果评论这些行:

     this.controllerFor('column').set('model',OlapApp.AxisModel.find());
    this.controllerFor('row').set('model',OlapApp.AxisModel.find());

我可以看到我的应用程序,但应用程序无法正常工作,我认为这些牵引线有错误。我还从 builds.emberjs.com 将 ember-data 更新到最新版本

【问题讨论】:

  • 您也在使用 ember 数据吗?如果是,是哪个版本?
  • 我从 ember data builds 下载 ember-data 并使用 FIXTURES 。

标签: ember.js ember-data


【解决方案1】:

发布的错误来自dimenssionTree,它应该在错误中提到的actions 对象中:

actions: {
    dimenssionTree: function () {
        return OlapApp.MeModel.find();
    }
}

就像你发现OlapApp.AxisModel.find() 应该写成this.store.find('AxisModel')。至于FIxtures可能很好看你的代码。

【讨论】:

    【解决方案2】:

    行:

    this.controllerFor('column').set('model', this.get('store').find('AxisModel'));
    

    应该阅读:

    this.controllerFor('column').set('model', this.get('store').find('axisModel'));
    

    主要区别是将AxisModel改为axisModel

    您可以阅读here 了解有关过渡的更多信息。

    希望对你有帮助。

    【讨论】:

      【解决方案3】:

      我换了

      this.controllerFor('column').set('model',OlapApp.AxisModel.find());
      

      this.controllerFor('column').set('model', this.get('store').find('AxisModel'));
      

      知道我可以看到我的应用程序,但我没有清除 FIXTURES 我收到一个错误,提示找不到 AxisModel 的任何 FIXTURE

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-07-02
        • 2022-12-09
        • 1970-01-01
        • 2022-11-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-11-27
        相关资源
        最近更新 更多