Weird, it seems the Module object does not get exported. Sorry it seems
vue.js related and I know nothing about it.


On Sat, Dec 28, 2019, 11:07 Marco Ippolito <[email protected]> wrote:

> I’m trying to transpose to vue.js this html page which works fine:
>
>     <!DOCTYPE html>
>     <html>
>       <head>
>         <meta charset="utf-8"/>
>       </head>
>       <body>
>         <input type="button" value="Add" onclick="callAdd()" />
>
>         <script>
>           function callAdd() {
>             const result = Module.ccall('Add',
>                 'number',
>                 ['number', 'number'],
>                 [1, 2]);
>             console.log(`Result: ${result}`);
>           }
>         </script>
>         <script src="js_plumbing.js"></script>
>       </body>
>     </html>
>
>
> According to the emscripten documentation:
> https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#calling-compiled-c-functions-from-javascript-using-ccall-cwrap
> we can use ccall and cwrap functions
>
>
> This is the Result.vue file:
>
>
>     <template>
>       <div>
>         <p button @click="callAdd">Add!</p>
>         <p>Result: {{ result }}</p>
>       </div>
>     </template>
>
>     <script>
>         import * as js_plumbing from './js_plumbing'
>         export default {
>           data () {
>             return {
>               result: null
>             }
>           },
>           methods: {
>             callAdd() {
>               const result = js_plumbing.Module.ccall('Add',
>                   'number',
>                   ['number', 'number'],
>                   [1, 2]);
>               console.log('Result: ${result}');
>               console.log(result);
>             }
>           }
>         }
>     </script>
>
>
> But when executing npm run dev
>
>
>      npm run dev
>
>     > [email protected] dev
> /home/marco/cpp/WebAssemblyinAction/Appendix_B/B.1_ccall/startingV
>     > cross-env NODE_ENV=development webpack-dev-server --open --hot
>
>
> I get this error: Cannot read property 'ccall' of undefined"
>
>
> How to solve it?
>
> Looking forward to your kind help.
>
> Marco
>
> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/emscripten-discuss/650b07f7-efc8-4132-94de-e556320b01ed%40googlegroups.com
> <https://groups.google.com/d/msgid/emscripten-discuss/650b07f7-efc8-4132-94de-e556320b01ed%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/CANLCay%3D3jWd9unVY_M34K_CNvaWVCfv%2B_3e0nf9BMfO4J%2BhGvA%40mail.gmail.com.

Reply via email to