问题描述
这两个函数都允许替换/修改绑定上下文并将其应用于未绑定的节点. 未绑定"表示要使用这些有用功能的我自己的自定义绑定必须始终在init
函数中返回{ controlsDescendantNodes: true }
.
Both functions allow to replace/modify binding context and apply it to unbound nodes. "Unbound" means that my own custom bindings that want to use these useful functions must always return { controlsDescendantNodes: true }
in init
function.
所以我不明白它们之间有什么区别?
So I cannot understand what the difference between them?
推荐答案
在ko.applyBindingsToNode
或3.0 ko.applyBindingAccessorsToNode
中使用时,您可以直接提供要用于特定元素的绑定(因此,它将不在乎data-bind
).
When using ko.applyBindingsToNode
or in 3.0 ko.applyBindingAccessorsToNode
you are able to directly supply the bindings that you want to use for a specific element (so, it would not care about data-bind
).
调用ko.applyBindingsToDecendants
时,您将应用已提供的根节点的子元素(默认为data-bind
属性中)上已经存在的绑定.
When calling ko.applyBindingsToDecendants
you would be applying the bindings that already exist on the child elements (in data-bind
attributes by default) of the supplied root node.
这篇关于ko.applyBindingsToNode与ko.applyBindingsToDescendants的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!