A simple calculator written in TinyGo and compiled to WebAssembly
简体中文
源代码
🏀🏀A simple calculator written in TinyGo and compiled to WebAssembly🏀🏀
bilibili 在线吹水
⚽️⚽️利用Go编写WebAssembly计算器、⚽️⚽️
Features
snapshot
- 挂载全局变量
const go = new Go(); // Defined in wasm_exec.js. Don't forget to add this in your index.html.
const importObject = go.importObject;
let wasmModule;
export const InitWasm = async () => {
wasmModule = await wasmBrowserInstantiate(wasmUrl, importObject);
go.run(wasmModule.instance);
}
export const ExpressionIt = (s) => {
let result
try {
result = window.expression(s)
} catch (e) {
console.log(e)
result = 'ERROR'
}
return result
};
- vue端导入
(async function () {
await InitWasm().then(() => {
createApp(App).mount('#app');
});
})();
- ts支持
export function InitWasm(): Promise<void>;
export function ExpressionIt(s: string): string;
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。