![](/img/trans.png)
[英]ember-data - store.find('model') always queries the server
[英]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.