[英]Ember - Page not getting displayed
我正在尝试我的第一个余烬应用程序。 它有两页。 一个页面是“欢迎”页面,另一页面列出了学生的详细信息。 所以我创建了两条路由,即index和studentdb 。 问题是我的第二页没有显示。 我在按照余烬指南的同时使用了Mirage 。 代码如下:
模板/index.hbs
<h1> Welcome </h1>
{{#link-to "studentdb"}}List{{/link-to}}
{{outlet}}
模板/studentdb.hbs
<h2> Welcome to Student Database </h2>
<h4> Following are the details </h4>
{{#each model as |student|}}
<p>Name: {{student.Name}}</p>
<p>College: {{student.College}}</p>
<p>Department: {{student.Department}}</p>
{{/each}}
{{outlet}}
路线/studentdb.js
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.store.findAll('student');
}
});
models / student.js(模型)
import DS from 'ember-data';
export default DS.Model.extend({
Name: DS.attr(),
College: DS.attr(),
Department: DS.attr()
});
海市rage楼/config.js
export default function() {
this.get('/student', function() {
return {
data: [{
type: 'student',
id: 1,
attributes: {
Name: 'Archana',
College: 'MNM Jain',
Department: 'CSE'
}
}, {
type: 'student',
id: 2,
attributes: {
Name: 'Monica',
College: 'Sathyabama',
Department: 'IT'
}
}, {
type: 'student',
id: 3,
attributes: {
Name: 'Manoj',
College: 'Kumarsaamy',
Department: 'MECH'
}
}]
}
});
}
router.js
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.route('studentdb');
});
export default Router;
请有人帮助。 提前致谢。
这是我在按照以下说明https://github.com/ember-cli/ember-cli/releases重新安装ember后得到的错误
npm WARN不推荐使用lodash-node@2.4.1:不再维护此软件包。 有关升级的详细信息,请参见其自述文件。 npm ERR! 解析json npm ERR的注册表错误! 解析json npm ERR的注册表错误! 解析json npm ERR的注册表错误! Windows_NT 6.1.7601 npm错误! argv“ C:\\ Program Files \\ nodejs \\\\ node.exe”“ C:\\ Program Files \\ nodejs \\ node_modules \\ npm \\ bin \\ npm-cli.js”“安装”“ -g”“ ember-cli@2.2。 0-beta.3“ npm错误! npm ERR! 如果您需要帮助,可以在以下位置报告此错误:npm ERR! http://github.com/npm/npm/issues
npm ERR! 请在支持请求中包含以下文件:npm ERR! C:\\ Users \\ learner \\ npm-debug.lo
请帮助。
您需要定义路线this.get('/students'
,它在内部使用ember-inflector来复数您的网址,根据jsonapi.org
我也是新手,也有同样的问题。 github上的以下问题使我意识到,我所遵循的指南比我在系统上安装的ember-cli版本要新:
https://github.com/samselikoff/ember-cli-mirage/issues/422
因此,我选择按照以下说明将ember更新到版本2.2.0-beta.3:
https://github.com/ember-cli/ember-cli/releases
在那之后,我还必须重新安装ember-cli-mirage,但随后它起作用了!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.