如何使scala.scalajs.js.typedarray类可用于scala.js跨项目的JVM构建?

时间:2019-06-01 23:56:19

标签: scala.js sbt-crossproject

当我尝试从JVM上运行的代码访问Uint8ClampedArray时,出现错误:java.lang.Error: A method defined in a JavaScript raw type of a Scala.js library has been called. This is most likely because you tried to run Scala.js binaries on the JVM. Make sure you are using the JVM version of the libraries.

哪个JVM库可以解决此运行时错误?

我们还有其他方法可以在sbt-crossprojects的JS和JVM版本之间共享此数据结构吗?

1 个答案:

答案 0 :(得分:0)

恐怕你不能。 Uint8ClampedArray是JavaScript标准库定义的类。它在JVM上根本不存在。

您可能希望查看java.nio.ByteBuffer的便携式解决方案,但请记住,它没有Uint8ClampedArray clamped 行为。如果需要,您必须使用自定义帮助程序。