将 @js.native 注释添加到 scalajs 上的特征时,@js.native 出现编译错误

compilation error on @js.native when added @js.native annotation to a trait on scalajs

我的编译器似乎没有识别出 @js.native。一般scalajs在项目中编译给我。

link to file(及其在失败的 github 中的项目)。

@js.native

上失败的文件来源
package example

import scala.scalajs.js
import js.annotation._

@js.native // sbt won't compile this native not found how to fix?
trait Funnel {

}

产量:

Funnel.scala:8: type native is not a member of package scala.scalajs.js [error] @js.native [error] ^ [error] one error found

sbt 供参考:

import com.lihaoyi.workbench.Plugin._

enablePlugins(ScalaJSPlugin)

workbenchSettings

name := "Example"

version := "0.1-SNAPSHOT"

scalaVersion := "2.11.5"

libraryDependencies ++= Seq(
  "org.scala-js" %%% "scalajs-dom" % "0.8.0",
  "com.lihaoyi" %%% "scalatags" % "0.5.4"
)

jsDependencies += "org.webjars" % "d3js" % "3.5.12" / "d3.js"

jsDependencies += ProvidedJS / "d3-funnel.js"

bootSnippet := "example.ScalaJSExample().main(document.getElementById('canvas'));"

updateBrowsers <<= updateBrowsers.triggeredBy(fastOptJS in Compile)

看起来你是 运行 scala.js 0.6.1。尝试将您的版本升级到 >= 0.6.5