123456789101112131415161718192021222324252627282930313233 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>WASM Demo</title>
- </head>
- <body>
- <div id="result"></div>
- <script>
- var div = document.getElementById('result');
- function test1(ex){
- div.innerText = 'add_two(1, 2) = ' + ex.add_two(1, 2);
- }
- window.addEventListener("load", function(){
- var env = { env: {
- print: (result) => { console.log('result = ', result); }
- } };
- WebAssembly.instantiateStreaming( fetch('add_two.wasm'), env).then( result => {
- console.log('WASM loaded!');
- var ex = result.instance.exports;
- console.log('ex = ', ex);
- test1(ex);
- });
-
- }, false);
- </script>
- </body>
- </html>
|