3秒后为什么this code没有变化?我做错了什么?
<div data-bind="visible: isBusy()">
is busy
</div>
<div data-bind="visible: !isBusy()">
is not busy
</div>
var viewModel;
function AppViewModel() {
var self = this;
self.isBusy = ko.observable(true);
}
function isNotBusyAnymore() {
viewModel.isBusy = ko.observable(true);
}
viewModel = new AppViewModel();
ko.applyBindings(viewModel);
setTimeout(isNotBusyAnymore, 3000);
答案 0 :(得分:3)
因为你不断制作新的可观察物......而且你的功能总是将它设置为“真实”
function isNotBusyAnymore() {
viewModel.isBusy(false);
}