使用以下代碼,輸入#p_in將隨著輸入#s_in的更改而更新。但是我已經(jīng)使用了cleanNode(sec)。任何人都可以幫助您理解為什么不清除綁定。 <input id="p_in" data-bind="value: name"></input> <input id="s_in" data-bind="value: name"></input> <input id="cb" type="checkbox">same</input> <script type="text/javascript"> function AddrDataSet (name) { this.name = ko.observable(name); }; var primary_set = new AddrDataSet('p'); var sec_set = new AddrDataSet('s'); var pri = $('#p_in')[0]; var sec = $('#s_in')[0]; ko.applyBindings(primary_set, pri); ko.applyBindings(sec_set, sec); ko.cleanNode(sec); // clean it ko.applyBindings(primary_set, sec); // bind it to primary_set ko.cleanNode(sec); // clean it again </script>
可以使用cleanNode()清除綁定嗎?
qq_遁去的一_1
2019-12-04 15:01:20