3

使用 Binding.scala 时,我无法编写使用 tabindex 属性的 html。这是 Binding.scala / scala.js 中的错误吗?

  <div>
    <input tabindex="1"></input>
    <input tabindex="3"></input>
    <br></br>
    <input tabindex="2"></input>
    <input tabindex="4"></input>
  </div>

导致编译错误:

ScalaFiddle.scala:12: error: value tabindex is not a member of scalajs.this.dom.html.Input
ScalaFiddle.scala:13: error: value tabindex is not a member of scalajs.this.dom.html.Input
ScalaFiddle.scala:15: error: value tabindex is not a member of scalajs.this.dom.html.Input
ScalaFiddle.scala:16: error: value tabindex is not a member of scalajs.this.dom.html.Input

我尝试使用属性(或属性?)tabIndex,但它不是字符串,并且属性参数需要是字符串。

例如看到这个:https ://scalafiddle.io/sf/kDg2uAA/0

我对 scala、sbt 和 scala.js 还是很陌生,所以我不确定在哪里/如何解决这个问题,以及如何在创建 pullrequest 之前在本地测试修复。

4

2 回答 2

2

您可以使用tabIndex包含在中的值的属性{}(提示:您可以在其中使用任何 scala 代码!)。

<div>
  <input tabIndex={1}></input>
  <input tabIndex={3}></input>
  <br></br>
  <input tabIndex={2}></input>
  <input tabIndex={4}></input>
</div>

请在此处查看完整代码:https ://scalafiddle.io/sf/hGkAVIb/1

于 2019-05-14T17:17:31.113 回答
1

您需要使用 data:tabindex 属性。请参阅https://scalafiddle.io/sf/TlcSdfF/1

于 2019-05-14T14:34:39.323 回答