Javascript 处理路由this.store.findALL时出现余烬数据错误不是函数
我目前正在浏览ember.js指南,我正在挂断关于ember数据的部分 本教程介绍如何创建一个余烬数据模型,并将其与幻影结合使用,在索引页上呈现一些基本的租金信息 我的代码似乎与教程相同(请参见底部的注释),但我的索引页没有显示任何内容,我在chrome控制台中遇到以下错误:Javascript 处理路由this.store.findALL时出现余烬数据错误不是函数,javascript,ember.js,ember-data,ember-cli-mirage,Javascript,Ember.js,Ember Data,Ember Cli Mirage,我目前正在浏览ember.js指南,我正在挂断关于ember数据的部分 本教程介绍如何创建一个余烬数据模型,并将其与幻影结合使用,在索引页上呈现一些基本的租金信息 我的代码似乎与教程相同(请参见底部的注释),但我的索引页没有显示任何内容,我在chrome控制台中遇到以下错误: 非常感谢任何人提供的任何帮助。这是我的app/models/rentals.js import Model from 'ember-data/model'; import attr from 'ember-data/att
非常感谢任何人提供的任何帮助。
这是我的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()
});
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'
}
}]
};
});
}
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.store.findALL('rental');
}
});
<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}}
app/mirage/config.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()
});
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'
}
}]
};
});
}
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.store.findALL('rental');
}
});
<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}}
app/routes/index.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()
});
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'
}
}]
};
});
}
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.store.findALL('rental');
}
});
<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}}
app/templates/index.hbs
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()
});
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'
}
}]
};
});
}
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.store.findALL('rental');
}
});
<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}}
欢迎来到Super Rentals
我们致力于帮助您!
{{{#每种型号为|租赁}
{{rent.title}
所有者:{{rental.Owner}
类型:{{rent.Type}
地点:{{rental.city}
卧室数量:{{出租.卧室}
{{/每个}}
{{{链接到“关于”}}关于我们!{{/链接到}
{{{链接到“联系”}联系我们!{{/链接到}
{{outlet}}
注意——ember.js指南与当前版本的ember有点过时,所以我也在使用ember-data.md文件。好吧,它的
store.findAll
不是store.findAll
!Javascript是区分大小写的。好吧,它的store.findAll
不是store.findAll
!Javascript区分大小写。谢谢!哈哈,我的显示器显示的方式有点误导人,事实上不是store.findALL
是未定义的
,这不是一个函数,所以您不能调用它。谢谢!哈哈,我的显示器显示的方式有点误导人,事实上不是store.findALL
是未定义的
,它不是一个函数,所以不能调用它。