【问题标题】:Ember "transition was aborted"Ember“过渡已中止”
【发布时间】:2014-02-25 19:18:42
【问题描述】:

我的 Ember App Kit 项目中有一条从 REST 服务获取的路由。这是代码:

var PatientsIndexRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, {
  model: function() {
    return this.store.find('patient').then(function(res) {
      console.log("success");
      return res;
    }, function() {
      console.log("error", arguments);
    });
  }
});

export default PatientsIndexRoute;

但是,当我导航到路线(在这种情况下为/patients/index)时,页面似乎什么也没做。这是控制台:

23:09:46.946 OPTIONS http://localhost:7000/patients/ [HTTP/1.0 200 OK 1ms]
23:09:46.881 "Attempting transition to patients.index" ember.js:3450
23:09:46.883 "Transition #3: patients.index: calling beforeModel hook" ember.js:3450
23:09:46.883 "Transition #3: patients.index: calling deserialize hook" ember.js:3450
23:09:46.948 GET http://localhost:7000/patients/ [HTTP/1.0 200 OK 4ms]
23:09:46.911 "success" app.js:171
23:09:46.912 "Transition #3: patients.index: calling afterModel hook" ember.js:3450
23:09:46.912 "Transition #3: Resolved all models on destination route; finalizing transition." ember.js:3450
23:09:46.915 "generated -> controller:patients.index" [object Object] ember.js:3450
23:09:46.918 "Transition #3: patients.index: transition was aborted" ember.js:3450

通知transition was aborted:这是一个一般性的消息,只要转换被中止,但我无法确定在哪里转换是从从中止的。我不认为它在获取模型时被中止,而是在afterModel 或setupController 之后的一段时间。

有趣的是,如果我删除 model 函数,它将导航到路线。也很奇怪:它呈现包装模板templates/patients.hbs,而不是templates/patients/index.hbs 模板。

编辑 1: 这是路由器:

var Router = Ember.Router.extend(); /

Router.map(function() {
  // Auth-example
  this.route('index', { path: '/' });
  this.route('protected');
  this.route('login');
  this.resource('patients', function() {
    this.route('new');
  });
});

export default Router;

【问题讨论】:

    标签: javascript ember.js ember-data


    【解决方案1】:

    我的问题是我缺少一个“patients.hbs”模板——我有一个“patients/new.hbs”和“patients/index.hbs”。要是能抱怨一下或者更具体一点就好了。

    【讨论】:

      猜你喜欢
      • 2015-01-12
      • 1970-01-01
      • 1970-01-01
      • 2013-06-30
      • 2017-05-25
      • 2013-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多