1234567891011121314151617181920212223242526272829303132333435 |
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>WASM test</title>
- </head>
- <body>
- <script>
- var importObject = {
- imports: {
- add: function(arg) {
- console.log(arg);
- }
- }
- };
- fetch('add.wasm').then(response =>
- response.arrayBuffer()
- ).then(bytes =>
- WebAssembly.instantiate(bytes, importObject)
- ).then(result =>
- console.log(result.instance.exports.add(1,2))
- );
- </script>
- </body>
- </html>
|