0
我想在更改复选框状态后更改可见属性。KnockoutJS如何观察对象属性?
我的代码(不行):
JS:
self.selectedItem = ko.observable({name:'myName', is_root: true})
HTML:
<span data-bind="visible:selectedItem().is_root">element is root!</span>
<input type="checkbox" data-bind="checked: selectedItem().is_root">
我在做什么错?
'is_root'必须是'ko.observable(真) '。你想成为“动态”的任何属性应该是“可观察的”。 – user3297291