Ember.js 为什么Ember 3.1在处理Ember数据代理对象时遇到问题?

Ember.js 为什么Ember 3.1在处理Ember数据代理对象时遇到问题?,ember.js,ember-data,Ember.js,Ember Data,我在Ember 3.1中有一个ES6类,它被交给一个名为certifciate的Ember数据对象。我希望能够对该证书调用.reload(),如下所示: @action showCertificateInfo(this: DomainCard, certificate) { this.setProperties({ isShowingCertificateModal: true, selectedCert: certificate, })

我在Ember 3.1中有一个ES6类,它被交给一个名为
certifciate
的Ember数据对象。我希望能够对该证书调用
.reload()
,如下所示:

  @action
  showCertificateInfo(this: DomainCard, certificate) {
    this.setProperties({
      isShowingCertificateModal: true,
      selectedCert: certificate,
    })
    certificate
      .reload()
      .then(() => {
        this.set('isShowingCertificateModal', true)
      })
      .catch(e => {
        // TODO: handle this
      })
    }
但是,如果我这样做,Ember会给出以下错误/警告:

Assertion Failed: You attempted to access the 'reload' property 
(of <DS.PRomiseObject:ember796>)... However in this case4 the object 
in quetstion is a special kind of Ember object (a proxy). Therefore,
it is still necessary to use` .get(‘reload’)` in this case.

我需要做什么才能正确重新加载此余烬数据对象?

从代理中拉出内容解决了问题:

const certContent = certificate.content || certificate
certContent.reload()

我仍然不确定为什么Ember 3.1不能正确使用代理,但这就是解决方案。

实际上,根本问题似乎是证书模型与域模型之间存在异步关系,并且通过使用
{async:false}
,我们不再需要将proxyPromise对象返回给我们,也不再需要将
内容
对象从proxyPromise中删除。

您的两个答案都不是答案。如果您想提供更多信息,请编辑您的原始帖子。您是否尝试过
证书。然后(c=>c.reload())
?是的,这不起作用。“您的两个答案都不是答案”@Lux--我不明白。下面提供的答案都解决了这个错误。也许在原始问题中显示模型信息会有所帮助?
const certContent = certificate.content || certificate
certContent.reload()