module = "blah"

The module attribute configures the module from which items are imported. For example,

#![allow(unused)]
fn main() {
#[wasm_bindgen(module = "wu/tang/clan")]
extern "C" {
    type ThirtySixChambers;
}
}

generates JavaScript import glue like

import { ThirtySixChambers } from "wu/tang/clan";

If a module attribute is not present, then the global scope is used instead. For example,

#![allow(unused)]
fn main() {
#[wasm_bindgen]
extern "C" {
    fn illmatic() -> u32;
}
}

generates JavaScript import glue like

let illmatic = this.illmatic;

注意,如果使用 module 指定的字符串以 ./..// 开头,则它被解释为指向 本地 JS 代码片段 的路径。如果这在你的用例中不起作用,你可能对 raw_module 属性 感兴趣。