<!-ko->和有什么不一样?绑定和可见绑定在淘汰赛中? [英] what is the difference between <!--ko--> binding and visible binding in knockout?

查看:78
本文介绍了<!-ko->和有什么不一样?绑定和可见绑定在淘汰赛中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ko <!--ko-->绑定和data-bind ="visible:sometext"绑定

ko <!--ko--> binding and data-bind="visible:sometext" binding

两种绑定都执行相同的操作,哪种绑定使用效率高,哪种绑定最好

Both binding did the same operation and which one is efficient for use and which one is best

推荐答案

<!-- ko [binding] -->允许您绑定到 data-bind="[binding]"是常规绑定,只能应用于实际元素.

data-bind="[binding]" is a regular binding and can only be applied to actual elements.

不同之处在于,无需创建元素就可以使用第一个:

The difference is that the first can be used without having to create an element:

<ul>
    <li class="heading">My heading</li>
    <!-- ko foreach: items -->
        <li data-bind="text: $data"></li>
    <!-- /ko -->
</ul>

请注意,并非每个绑定处理程序都可以应用于虚拟元素:

Do note that not every binding handler can be applied to an virtual element:

自定义绑定也可以与虚拟元素一起使用,但是要启用 为此,您必须明确告知Knockout您的绑定可以理解 虚拟元素,方法是使用ko.virtualElements.allowedBindings API.

Custom bindings can work with virtual elements too, but to enable this, you must explicitly tell Knockout that your binding understands virtual elements, by using the ko.virtualElements.allowedBindings API.

这篇关于&lt;!-ko-&gt;和有什么不一样?绑定和可见绑定在淘汰赛中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆