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

How can I make scala.scalajs.js.typedarray classes available to JVM builds of scala.js crossprojects?

当我尝试从 JVM 上的代码 运行ning 访问 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 构建共享此数据结构?

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

您可能想查看 java.nio.ByteBuffer 的便携式解决方案,但请记住,它没有 Uint8ClampedArrayclamped 行为.如果需要,您必须包装一个自定义助手。