在这个例子中我一定遗漏了一些东西。谁能让我知道可能出了什么问题?
链接:http: //jsfiddle.net/EBxy4/42/
屏幕:共享屏幕
当您更新第 1 行中框 1 中的值时,下角的值不会改变。
代码是:
function revenueStream(w1, w2, w3) {
var self = this;
self.week1Amount = ko.observable(w1);
self.week2Amount = ko.observable(w2);
self.week3Amount = ko.observable(w3);
}
function revenueStreamCategory(revenueStreams) {
var self = this;
self.revenueStreams = ko.observalrevenueStreams;
self.week1Sum = ko.computed(function () {
var sum = 0.0;
ko.utils.arrayForEach(self.revenueStreams, function(item) {
sum += item.week1Amount();
});
return sum;
});
}
var rs = [];
rs.push(new revenueStream(10, 11, 12));
rs.push(new revenueStream(13, 14, 15));
rs.push(new revenueStream(16, 17, 18));
var vm = new revenueStreamCategory(rs);
ko.applyBindings(vm, document.getElementById("test"));