gpt4 book ai didi

knockout.js - knockout "controlsDescendantBindings"用法

转载 作者:行者123 更新时间:2023-12-04 04:54:32 26 4
gpt4 key购买 nike

有人可以向我解释一下 controlsDescendantBindings 的确切用法吗?在 knockoutjs

到目前为止我得到的结果是Hey KO stop your binding on the descendants of the current element(the element i'm bind my custom binding to), i'll take care of binding to these descendants我对吗 ?

我做的很简单 Fiddle Demo 但我不明白为什么只有第一个 span仅在我对此发表评论时更新 return { controlsDescendantBindings: true };

最佳答案

实际上,如果您检查此 page 的第一个示例它明确指出

"If the value is false, then allowBindings tells Knockout that it is responsible for descendant bindings so they won’t be bound as usual."


<div data-bind="withProperties: { emotion: 'happy' }">
Today I feel <span data-bind="text: emotion"></span>. <!-- Displays: happy -->
</div>

在带有“data-bind=withProperities”的 fiddle div 中有一个子元素跨度。如果 控制DescendantBindings 是错误的,它不会将子跨度传递给 knockout 进行处理。我的理解是您可以控制 KO 是否应该处理自定义绑定(bind)的子元素。

关于knockout.js - knockout "controlsDescendantBindings"用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16939660/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com