# 编译
wasm-pack build --target web
# 修复代码错误
node replace.js
# 复制文件
copy pkg\hello.js wasm-bindgen-test\pages\index\hello.js
copy pkg\hello_bg.wasm wasm-bindgen-test\pages\index\hello.wasm
Cannot use 'import.meta' outside a module
SyntaxError: Cannot use 'import.meta' outside a module
删除以下代码
if (typeof input === 'undefined') {
input = new URL('wx_qrcode.wasm', import.meta.url);
}
ReferenceError: WebAssembly is not defined
将编译好的hello.js中的所有"WebAssembly"替换为"WXWebassembly"
TypeError: fetch is not a function
删除以下代码
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
input = fetch(input);
}
真机运行报错
Can't find variable: TextDecoder
在 hello.js中引入encoding_utf8.min.js