Ember 处理路由时出现数据错误 this.store.findALL 不是函数

Ember Data error while processing route this.store.findALL is not a function

我目前正在阅读 ember.js 指南,但在 Ember 数据 部分挂断了电话。 Ember Data Guide

本教程展示了如何创建 Ember 数据模型并将其与 Mirage 结合使用以在索引页面上呈现一些基本的租赁信息。

我的代码似乎与教程相同(见底部注释),但我的索引页面没有显示任何内容,我在 chrome 控制台中收到以下错误:


任何人都可以提供任何帮助,我们将不胜感激。


这是我的app/models/rentals。 js

import Model from 'ember-data/model';
import attr from 'ember-data/attr';

export default Model.extend({
    title: attr(),
    owner: attr(),
    city: attr(),
    type: attr(),
    image: attr(),
    bedrooms: attr()
});

app/mirage/config.js

export default function() {
  this.get('/rentals', function() {
    return {
      data: [{
        type: 'rentals',
        id: 1,
        attributes: {
          title: 'Grand Old Mansion',
          owner: 'Veruca Salt',
          city: 'San Francisco',
          type: 'Estate',
          bedrooms: 15,
          image: 'https://upload.wikimedia.org/wikipedia/commons/c/cb/Crane_estate_(5).jpg'
        }
      }, {
        type: 'rentals',
        id: 2,
        attributes: {
          title: 'Urban Living',
          owner: 'Mike Teavee',
          city: 'Seattle',
          type: 'Condo',
          bedrooms: 1,
          image: 'https://upload.wikimedia.org/wikipedia/commons/0/0e/Alfonso_13_Highrise_Tegucigalpa.jpg'
        }
      }, {
        type: 'rentals',
        id: 3,
        attributes: {
          title: 'Downtown Charm',
          owner: 'Violet Beauregarde',
          city: 'Portland',
          type: 'Apartment',
          bedrooms: 3,
          image: 'https://upload.wikimedia.org/wikipedia/commons/f/f7/Wheeldon_Apartment_Building_-_Portland_Oregon.jpg'
        }
      }]
    };
  });
}

app/routes/index.js

    import Ember from 'ember';

    export default Ember.Route.extend({
      model() {
        return this.store.findALL('rental');
      }
    });

app/templates/index.hbs

<h3>Welcome to Super Rentals</h3>

<p>
  We are dedicated to helping you!
</p>

{{#each model as |rental|}}
  <h2>{{rental.title}}</h2>
  <p>Owner: {{rental.owner}}</p>
  <p>Type: {{rental.type}}</p>
  <p>Location: {{rental.city}}</p>
  <p>Number of Bedrooms: {{rental.bedrooms}}</p>
{{/each}}

{{#link-to "about"}}About Us!{{/link-to}}
{{#link-to "contact"}}Contact Us!{{/link-to}}


{{outlet}}

注意——ember.js 指南与 ember 的当前版本略有过时,所以我也使用 these edits ember-data.md 文件.

好吧,它 store.findAll 不是 store.findALL! Javascript 区分大小写。