我在使用排序功能加载 webassembly 文件时遇到问题,它显示此错误:
TypeError: WebAssembly.instantiate(): Import #0 module="wbg" error: module is not an object or function
编译代码:
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn bubble_sort(arr: &mut [i32]) {
let mut swapped = true;
while swapped {
swapped = false;
for i in 1..arr.len() {
if arr[i - 1] > arr[i] {
arr.swap(i - 1, i);
swapped = true
}
}
}
}
WebAssembly.instantiateStreaming(
fetch("./wasm_example_bindgen_bg.wasm"),
{}
).then((wa) => {
console.log(wa.instance.exports.bubble_sort([10,11]));
});
可能是什么问题? 版本: wasm-bindgen-cli 0.2.74 铁锈 1.67
我正在尝试制作一个带有冒泡排序的排序应用程序。