【发布时间】:2019-09-22 12:26:10
【问题描述】:
在webassembly.org,JS API页面中,在javascript中导入WebAssembly的方式是
fetch('example.wasm').then(response => response.arrayBuffer())
.then(bytes => instantiate(bytes, importObject))
.then(instance => instance.exports.e());
emcc 发出的 js 文件似乎是这样做的。
但是当我对 Rust 的 Cargo 使用 wasm-pack 时,javascript 文件只执行 import * as wasm from './example.wasm'
这两者有什么区别?直接导入是新支持的功能吗?当使用直接导入时,我将如何从 javascript 访问 WebAssembly 的内存,因为我没有像使用第一种方法那样将它们传递给 WebAssembly 模块?
【问题讨论】:
-
我相信您的各种问题都已得到解答here,但我还没有深入到它的基础上发布完整的答案。
标签: javascript emscripten webassembly