Some text 0--> Some other -6ren">
gpt4 book ai didi

javascript - knockout "if"和 "ifnot"不起作用

转载 作者:行者123 更新时间:2023-11-28 18:55:39 25 4
gpt4 key购买 nike

我正在使用 knockout 并有此代码

self.array = ko.observableArray([]);

HTML

<!--ko if: array().length > 0-->
<tr>
<td>Some text</td>
</tr>
<!--/ko-->
<!--ko ifnot: array().length > 0-->
<tr>
<td>Some other text</td>
</tr>
<!--/ko-->

我正在使用其他一些 knockout 语句,它们有效,但这个不起作用,我不明白为什么。有人可以帮我吗?

最佳答案

似乎在表格内使用虚拟元素需要使用包装 <tbody>元素。

看我的 fiddle : http://jsfiddle.net/yq9v7d0g/2/

一旦我添加了<tbody>元素,一切正常。这曾经是 Internet Explorer 中的一个问题,但现在似乎又成为一个问题。

关于javascript - knockout "if"和 "ifnot"不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33679677/

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