【发布时间】:2017-05-22 04:49:52
【问题描述】:
出于某种原因,EmberJS 不会填充用 camelCase 编写的模型属性。我使用 JSONAPIAdapter(RESTAdapter 不是一个选项)。 这是我的模型:
import DS from 'ember-data';
export default DS.Model.extend({
shortName: DS.attr('string'),
fullName: DS.attr('string'),
inn: DS.attr('string'),
kpp: DS.attr('string'),
checkingAccount: DS.attr('string'),
correspodentAccount: DS.attr('string'),
bik: DS.attr('string'),
});
我的车把模板:
{{#each model as |company|}}
<tr class="companies-list__item">
<td class="companies-list__property">{{company.shortName}}</td>
<td class="companies-list__property">{{company.inn}}</td>
<td class="companies-list__property">{{company.kpp}}</td>
<td class="companies-list__property">{{company.checkingAccount}}</td>
<td class="companies-list__property">{{company.correspodentAccount}}</td>
<td class="companies-list__property">{{company.bik}}</td>
</tr>
{{/each}}
来自服务器的答案如下所示:
{
type: 'company',
id: 4,
attributes: {
shortName: 'Рога и копыта',
fullName: 'ООО Рога и копыта',
inn: '312312312',
kpp: '767675572',
checkingAccount: '3123145124',
correspodentAccount: '6547598',
bik: '76979356'
},
},
它确实填充了 inn、kpp、bik,但不使用其他。有什么问题?
【问题讨论】:
-
你有访问服务器的权限吗?
标签: json ember.js ember-data json-api