我是ember js的新手,我想从json文件中获取数据,我不会在浏览器中获取任何输出。
应用/路线/ index.js
import Ember from 'ember';
export default Ember.Route.extend({
model: function(){
return this.$.getJSON("app.json");
}
});
应用/模板/ index.hbs
<h1> I won {{tot}} today! </h1>
app.json
{ "tot": 100}
是否必须使用适配器概念从json文件中呈现数据?
答案 0 :(得分:2)
当我们使用Ember 1.x时,我们使用这种符号来访问模型的值,即。
{{tot}}
而不是
{{model.tot}}
但是现在如果有模型,则应该使用
进行访问{{model.propertyName}}
答案 1 :(得分:1)
您必须通过模型访问数据,即
<h1> I won {{model.tot}} today! </h1>