Bind <svelte:window> to `onbeforeunload`
问题 I was hoping to bind to <svelte:window> but have no luck. <!-- doesn't work --> <svelte:window on:beforeunload={() => true} /> <!-- doesn't work --> <svelte:window on:onbeforeunload={() => true} /> <!-- doesn't work --> <svelte:window on:beforeUnload={() => true} /> in all instances, window.onbeforeunload is null I ended up just going with window.onbeforeunload = () => true but was wondering why setting on the element didn't work. 回答1: You need to set the event returnValue when using svelte