类型错误:WebAssembly 实例化:导入参数必须存在并且必须是一个对象 [英] TypeError: WebAssembly Instantiation: Imports argument must be present and must be an object
问题描述
我正在关注这个你好世界"教程:https://steemit.com/eos/@skenan/eos-面向初学者的 webassembly 开发
I'm following this "hello world" tutorial: https://steemit.com/eos/@skenan/eos-development-for-beginners-webassembly
我收到此错误:
TypeError: WebAssembly Instantiation: Imports 参数必须存在并且必须是一个对象
TypeError: WebAssembly Instantiation: Imports argument must be present and must be an object
知道是什么原因造成的吗?
Any idea what might be causing it?
推荐答案
您收到此错误的原因可能是:当您启动 webassembly 实例时,您还需要指定导入对象.就像:
The reason you got this error is probably because: when you initiate a webassembly instance, you need to specify the import object as well. Just like:
WebAssembly.instantiate(module, imports);
好吧,这里我只是举一个简单的例子来演示步骤:
Well, here I'm just giving a simple example to demonstrate the steps:
imports.env = imports.env || {}
Object.assign(imports.env, {
tableBase: module.tableBase,
table: new WebAssembly.Table({
initial: 4,
element: 'anyfunc',
}),
print:function(msg){
console.log(msg);
}
});
return new WebAssembly.Instance(module, imports)
这篇关于类型错误:WebAssembly 实例化:导入参数必须存在并且必须是一个对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!