TypeError: undefined is not an object (evaluating 'window.wails.Events.OnMultiple')
wails 版本信息: wails version : v2.10.1
主要代码如下:
`import { Events } from "@wailsapp/runtime";
Events.On("directoryUpdated", updateImageList);
` 然后就报错了:
I'm having this issue as well. Is there a solution to this?
TypeError: undefined is not an object (evaluating 'window.runtime.EventsOnMultiple')
I am also getting this issue. Is EventsOnMultiple supposed to be deprecated? My code references EventsOn only.
import { Events } from "@wailsapp/runtime"
Where did this come from? The runtime should be in frontend/wailsjs/runtime
When you get this, can you check if window.runtime or window.runtime.EventsOnMultiple is null
Strangely enough I was able to eventually get it to work without throwing this error. I'm not even sure what I did as I did multiple things like
running go clean -cache and go clean -modcache
rm -rf node_modules dist wailsjs
rebooting
something eventually worked, but I'm not sure. I did grep the directory looking for references and I saw the following:
❯ grep -R 'EventsOnMultiple' frontend/wailsjs
frontend/wailsjs/runtime/runtime.d.ts:// [EventsOnMultiple](https://wails.io/docs/reference/runtime/events#eventsonmultiple)
frontend/wailsjs/runtime/runtime.d.ts:export function EventsOnMultiple(eventName: string, callback: (...data: any) => void, maxCallbacks: number): () => void;
frontend/wailsjs/runtime/runtime.js:export function EventsOnMultiple(eventName, callback, maxCallbacks) {
frontend/wailsjs/runtime/runtime.js: return window.runtime.EventsOnMultiple(eventName, callback, maxCallbacks);
frontend/wailsjs/runtime/runtime.js: return EventsOnMultiple(eventName, callback, -1);
frontend/wailsjs/runtime/runtime.js: return EventsOnMultiple(eventName, callback, 1);
I'm not sure if that helps. If it pops back up, I'll post back.
OK I realized I only get this when I use wails dev and I attempt to refresh with the app UI by right clicking and selecting 'refresh'. I see the following:
To answer your question if window.runtime is undefined, it is:
The directory does exist:
My current fix when running from wails dev, is to close the app, and restart wails dev.