我有以下视图模型:
function vm(model) {
var self = this;
var Create = function (data) {
var order = ko.utils.extend(data, {});
order.Price = ko.observable(data.Price);
return order;
}
self.orders = ko.mapping.fromJS(model, {
create: function (options) {
return Create(options.data);
}
});
self.FirstPrice = ko.pureComputed(function () {
return parseFloat(self.orders()[0].Price());
});
}
页面加载时“FirstPrice”正常更新,但更改“orders”数组第一行的Price后,“FirstPrice”仍然是页面加载后的第一个值。
什么不见了?
* 我删除了一些代码行以简化示例
谢谢