You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ember 1.12中两个Ember Data模型表现不一致问题排查

Ember 1.12 模型传递异常问题

在Ember 1.12版本中,我遇到一个持续存在的问题:同一个路由传递的两个模型里,一个能正常工作,另一个却不符合预期。

路由代码(search.js)

model(params) {
  this.set('searchParams', params);
  this.store.unloadAll('search');
  this.store.unloadAll('sceneai');

  return Ember.RSVP.hash({
    sceneai: this.store.findQuery('sceneai', params.q),
    searchResults: this.store.findQuery('search', params)
  });
},

renderTemplate(controller, model) {
  this._super(controller,model);
  var folderController = this.controllerFor('files.folder');
  folderController.set('model', model.searchResults);

  this.render('files.folder', {
    into: 'search',
    outlet: 'results',
    controller: folderController
  });

  // 为'vectorResults'出口创建第二个文件夹控制器
  let vectorFolderController = this.controllerFor('files.vector');
  vectorFolderController.set('model', model.sceneai);

  this.render('files.vector', {
    into: 'search',
    outlet: 'vectorResults',
    controller: vectorFolderController
  });
}

模板表现差异

  • 正常工作的folder.hbs:使用标准写法即可渲染数据
{{#each model as |item|}}
  {{item.path}}
{{/each}}
  • 异常的vector.hbs:必须使用非标准写法才能获取数据,这种写法不符合常规用法,还会破坏后续文件链
{{#each model.content as |item|}}
  {{item._data.path}}
{{/each}}

模型状态截图

  • 异常模型(包含4个内容项):
    异常模型(含4个内容项)

  • 正常模型(包含2个内容项):
    正常模型(含2个内容项)

内容的提问来源于stack exchange,提问作者Ramix

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 20:12:10