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