gpt4 book ai didi

html - 你如何将一个字符串连接到一个 div 类名?

转载 作者:行者123 更新时间:2023-11-28 01:37:18 24 4
gpt4 key购买 nike

例如,<div class="hi_" + "1">(这是行不通的)

用例是如果我在 Handlebars 中进行模板化并且我的代码是:

{{#each this}}
<div class="box_" + {{id}}>
{{/each}}

我将如何命名我的 div?

最佳答案

您可以像这样简单地将占位符插入到类属性中:

{{#each this}}
<div class="box_{{ id }}"></div>
{{/each}}

关于html - 你如何将一个字符串连接到一个 div 类名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27627303/

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