我正在webassembly.org上运行教程,现在我想hello.wasm
从我自己的页面运行。我正在按照教程的说明使用Emscripten编译代码。
按照我正在做的这些说明index.html
:
const instantiate = (bytes, imports = {}) =>
WebAssembly.compile(bytes).then(m =>
new WebAssembly.Instance(m, imports)
)
fetch('hello.wasm')
.then(response => response.arrayBuffer())
.then(bytes => instantiate(bytes, {}))
但我得到这个错误:
所以我尝试WebAssembly.instantiate()
从MDN 文档中使用以下代码:
const instantiate = (bytes, imports = {}) =>
WebAssembly.compile(bytes).then(m =>
WebAssembly.instantiate(m, imports)
)
我得到一个不同的:
知道如何解决吗?