我是ember.js的新手,最近我遇到了这样的问题
Assertion Failed: You attempted to define a `{{link-to "cryptid"}}` but did not pass the parameters required for generating its dynamic segments. More context objects were passed than there are dynamic segments for the route: cryptid
我将在下面显示我的代码,任何人都可以解释哪里出了问题以及如何解决?
在模型中(cryptid.js)
import DS from 'ember-data';
export default DS.Model.extend({
name: DS.attr('string'),
cryptidType: DS.attr('string'),
profileImg: DS.attr('string'),
sightings: DS.hasMany('sighting')
});
在路由中(crypteds.js)
import Route from '@ember/routing/route';
export default Route.extend({
model(){
return this.store.findAll('cryptid');
}
});
在cryptids.hbs中
<div class="row">
{{#each model as |cryptid|}}
<div class="col-xs-12 col-sm-3 text-center">
<div class="media well">
{{#link-to 'cryptid' cryptid.id}}
<img class="media-object thumbnail" src="{{if cryptid.profileImg cryptid.profileImg 'assets/images/cryptids/blank_th.png'}}" alt="{{cryptid.name}}" width="100%" height="100%">
{{/link-to}}
<div class="caption">
<h3>{{cryptid.name}}</h3>
</div>
</div>
</div>
{{else}}
<div class="jumbotron">
<h1>No Creatures</h1>
</div>
{{/each}}
</div>
在router.js中
Router.map(function() {
this.route('sightings', function() {
this.route('new');
});
this.route('sighting', function() {
this.route('edit');
});
this.route('cryptids');
this.route('cryptid'), {path: 'cryptids/:cryptid_id'};
this.route('witnesses');
this.route('witness');
});