Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ember.js 使用自引用时的未捕获错误与余烬数据有很多关系_Ember.js_Ember Data - Fatal编程技术网

Ember.js 使用自引用时的未捕获错误与余烬数据有很多关系

Ember.js 使用自引用时的未捕获错误与余烬数据有很多关系,ember.js,ember-data,Ember.js,Ember Data,我已使用余烬数据定义了以下模型: App.Person = DS.Model.extend({ name: DS.attr('string'), parent: DS.belongsTo('person'), children: DS.hasMany('person') }); 此外,我还定义了以下夹具数据,这些数据对数据进行了适当的建模,表明Ember数据在此布局中对数据进行建模没有问题: App.Person.FIXTURES = [ {id: 1, name: "Dyla

我已使用余烬数据定义了以下模型:

App.Person = DS.Model.extend({
  name: DS.attr('string'),
  parent: DS.belongsTo('person'),
  children: DS.hasMany('person')
});
此外,我还定义了以下夹具数据,这些数据对数据进行了适当的建模,表明Ember数据在此布局中对数据进行建模没有问题:

App.Person.FIXTURES = [
  {id: 1, name: "Dylan", parent: 2},
  {id: 2, name: "Stacey", children: [1,3]},
  {id: 3, name: "Londyn", parent: 2},
  {id: 4, name: "Kyle"}
];
尝试创建记录时,我收到一条毫无帮助的错误消息:

Uncaught #<error>
未捕获#
只有在模型上定义了子属性时,才会发生这种情况。删除它将导致成功创建记录,而不会出现错误

我还举了一个简单的例子

您可以阅读有关inverse的内容

您在没有固定装置的情况下工作过吗?或者更好,没有基于整数的ID?在我尝试改进我的URL之前,我已经有了这个功能,但是现在即使有了这个功能,它也被破坏了。
children: DS.hasMany('person', { async: true, inverse: 'parent' } )