wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
25.34k stars 1.22k forks source link

wails is not defined for events management #520

Closed fedyfausto closed 4 years ago

fedyfausto commented 4 years ago

Hello guys| I'm trying to use wails to make a small desktop application and i'm using Vue framework. Acutally i'm going to manage an event on mounted component but the application does not work (and some time even the build!) and says that

16:5  error  'wails' is not defined  no-undef

some help?

JS code:

 mounted: function() {
    wails.events.on("message", message => {
        if (cpu_usage) {
            message.log(message);
        }
    });
leaanthony commented 4 years ago

Try wails.Events.On. Case matters in JS land 😃 The API changed at V1 to make it consistent with the Go runtime.

fedyfausto commented 4 years ago

But the problem is that wails object is undefined

Il giorno 5 ott 2020, alle ore 21:16, Lea Anthony notifications@github.com ha scritto:



Try wails.Events.On. Case matters in JS land 😃

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/wailsapp/wails/issues/520#issuecomment-703834773, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AA53P4FWX6TAFNIBK6L7HFTSJILRBANCNFSM4SE4KJZA.

leaanthony commented 4 years ago

Maybe provide more information like a link to your project. Is this at runtime/compile time? Did you wrap your code in the Init() command callback? The wails object exists on window. Did you update your webpack to not allow accessing window?

fedyfausto commented 4 years ago

ah ok thanks!, resolved!