我试图消除我最近在我的代码中引入的弃用,我需要一些帮助.
弃用是:
您在单个渲染中修改了两次... 这在Ember 1.x中是不可靠的,将在Ember 2.0中删除[弃用ID:ember-views.render-double-modify]
我要做的是显示一个分数列表,然后显示总分.我需要降低最低分,而不是将其包含在计算总数中.我有这个工作.当我尝试通过classNameBindings将CSS类添加到已排除的分数时,就会弃用.
我很确定当我在computedTotal的计算属性中执行Ember.set时会发生这种情况.
我的问题是,当我在表单中更改分数时,如何更新CSS的总分更新?
代码细节:我有两个组件; 得分排和判断排.分数行包含一系列分数对象,循环通过每个分数调用法官分数组件.
Ember : 2.2.0
Ember Data : 2.2.1
Run Code Online (Sandbox Code Playgroud)
更新这里有一个工作的Ember Twiddle演示了这个问题:
https://ember-twiddle.com/6696d907b604aa750201?numColumns=1
index.js - (针对此问题提取的模拟代码)
let scores = new Ember A();
scores.pushObject(Ember.Object.create({ points: 1 }));
scores.pushObject(Ember.Object.create({ points: 2 }));
scores.pushObject(Ember.Object.create({ points: 3 }));
Run Code Online (Sandbox Code Playgroud)
index.hbs
{{score-row scores=scores}}
Run Code Online (Sandbox Code Playgroud)
记分row.hbs
{{#each scores as |score|}}
{{judge-score score=score}}
{{/each}}
{{calculatedTotal}}
Run Code Online (Sandbox Code Playgroud)
记分row.js:
calculatedTotal: Ember.computed('scores.@each.points', () => {
let totalScore = 0,
scores = this.get('scores');
if(Ember.isPresent(scores)) {
var i,
scoresLength = scores.length,
sortedAscending,
numLowToDrop …Run Code Online (Sandbox Code Playgroud)