我无法绑定这个:
js:
function User(jsonModel) {
self.show= ko.observable(jsonModel.show);
}
function ViewModel(jsonModel) {
var self = this;
self.user = ko.observable(new User(jsonModel.User));
}
对此:
<input id="it" type="checkbox" data-bind="checked: user.show" />
无论如何,该复选框都未选中。我还在这里检查了 viewModel .user() = true :
var viewModel = new ViewModel(json);
ko.applyBindings(viewModel);