如何在 Scalatags 中添加 "data-" 属性

How to ad "data-" attributes in Scalatags

我想使用 "data-" 表示法定义具有扩展属性的输入。例如定义:

<input type="radio" id="3" data-extra="three"/>

有没有办法在 Scalatags 中做到这一点?

您可以使用 "data-extra".attr 创建自定义属性。例如

input(tpe := "radio", id := "3", "data-extra".attr := "three")

最方便的方法是使用data(...):

input(tpe := "radio", id := 3, data("extra") := "three")

现在甚至

input(tpe := "radio", id := 3, data.extra := "three")