我在淘汰赛中的关系有些问题。
在我的项目中,我将项目从 constructionTypes 复制到 currentWindow.constructionParamets 然后更改
this.currentWindow().constructionParametres().items()[0].currentStep(2)
但它在 constructionTypes 上也发生了变化。我尝试了 slice(),但没有成功。
我应该怎么办?
谢谢。
function ReservationsViewModel() {
this.constructionTypes = ko.observableArray([
{ id: 1, items: ko.observableArray([
{ type: 1, currentStep: ko.observable(1), steps: []},
{ type: 0, currentStep: ko.observable(1), steps: []},
{ type: 0, currentStep: ko.observable(1), steps: []},
{ type: 0, currentStep: ko.observable(1), steps: []}
])
},
{ id: 2, items: ko.observableArray([
{ type: 1, currentStep: ko.observable(1), steps: []},
{ type: 2, currentStep: ko.observable(1), steps: []},
{ type: 0, currentStep: ko.observable(1), steps: []},
{ type: 0, currentStep: ko.observable(1), steps: []}
])
}
]);
this.currentWindow = ko.observable({
id: ko.observable(0),
name: ko.observable('Need 1'),
constructionParametres: ko.observable( this.constructionTypes().slice()[0] )
});
this.currentWindow().constructionParametres().items()[0].currentStep(2);
this.currentWindow().constructionParametres().items()[0].currentStep(3);
}
ko.applyBindings(new ReservationsViewModel());