类型错误:WebAssembly 实例化:导入参数必须存在并且必须是一个对象 [英] TypeError: WebAssembly Instantiation: Imports argument must be present and must be an object

查看:78
本文介绍了类型错误:WebAssembly 实例化:导入参数必须存在并且必须是一个对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注这个你好世界"教程: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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆