如果不是列表迭代中的元素,则隐藏元素(Hide element if not element in a list iteration)

编程入门 行业动态 更新时间:2024-10-17 11:32:00
如果不是列表迭代中的元素,则隐藏元素(Hide element if not element in a list iteration)

所以我在2个字段中有2个字符串列表, altTextimagecaption 。 我把它们包裹在一个div中。 我希望在循环的每次迭代中,如果在某些循环中都没有内容,则使div不渲染。 我该怎么做?

30 = COA 30{ wrap = <div class="case-info">|</div> required = 1 30 = TEXT 30{ wrap = <div>|</div> field = altText listNum.splitChar = 10 listNum.stdWrap.data = register:SPLIT_COUNT required = 1 } 40 < .30 40.field = imagecaption }

html的输出是这样的:

<div class="case-info"> <div></div> <div></div> </div>

So I have 2 list of string in 2 fields, altText and imagecaption. I have them wrapped in a div. I want to make the div not render if neither have content in some loop, on each iteration of the loop. How can I do it?

30 = COA 30{ wrap = <div class="case-info">|</div> required = 1 30 = TEXT 30{ wrap = <div>|</div> field = altText listNum.splitChar = 10 listNum.stdWrap.data = register:SPLIT_COUNT required = 1 } 40 < .30 40.field = imagecaption }

The output of html is this:

<div class="case-info"> <div></div> <div></div> </div>

最满意答案

删除包装并以这种方式尝试:

30 = COA 30{ stdWrap.required = 1 stdWrap.wrap = <div class="case-info">|</div> 30 = TEXT 30{ field = altText listNum.splitChar = 10 listNum.stdWrap.data = register:SPLIT_COUNT trim = 1 required = 1 wrap = <div>|</div> } 40 < .30 40.field = imagecaption }

所以,如果有内容(required = 1),只会执行换行

Remove the wrap and try it this way:

30 = COA 30{ stdWrap.required = 1 stdWrap.wrap = <div class="case-info">|</div> 30 = TEXT 30{ field = altText listNum.splitChar = 10 listNum.stdWrap.data = register:SPLIT_COUNT trim = 1 required = 1 wrap = <div>|</div> } 40 < .30 40.field = imagecaption }

so, the wrap will only executed, if there is content (required = 1)

更多推荐

本文发布于:2023-07-25 05:44:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1256808.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:元素   如果不是   迭代   列表   iteration

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!