簡體   English   中英

`store.find` function 與 Ember JS 上的 `store.findRecord` function 不同嗎?

[英]Is `store.find` function different to `store.findRecord` function on Ember JS?

Ember JS 服務“store”上有兩個類似的功能。 在此示例中,它們的工作方式相似。

find function

  @service store;

  async model(params) {
    return this.store.find('rental', params.rental_id);
  }

查找記錄findRecord

  @service store;

  async model(params) {
    return this.store.findRecord('rental', params.rental_id);
  }

他們有什么不同嗎? 或者只是一個別名?

store.find是私有的且已棄用。 store.findRecord是通過 id 查找特定記錄的正確方法。

您可以在此處查看更多詳細信息。

存儲.查找

// The default `model` hook in Route calls `find(modelName, id)`,
// that's why we have to keep this method around even though `findRecord` is
// the public way to get a record by modelName and id.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM