svelte-3

Svelte 3, async onMount or a valid alternative?

ε祈祈猫儿з 提交于 2020-06-14 15:30:51
问题 What I need is to use async-await in Svelte onMount() . Or maybe you can suggest me what is wrong and what I can use alternatively. To Reproduce go here: https://svelte.dev/repl/000ae69c0fe14d9483678d4ace874726?version=3.23.0 open the console click on the button you should see messages: "Mounting..." and "A lot of background work..." if you click again the destroy message is not written WHY? Did onMount() recognizes the async function promise? Should it? I need that async behavior because I

Access Component Object in External Callback?

别来无恙 提交于 2019-12-11 15:54:25
问题 In the following code, in which submit is a method in an external JavaScript module, is it possible for submit() to access the component object? Component.html <button on:click={submit}>Submit</button> <script> import { submit } from './'; </script> index.js export function submit() { console.log(this); // <button>Submit</button> }; Before Svelte 3, this would be the component object, but in Svelte 3, this seems to be the target element. 来源: https://stackoverflow.com/questions/57571882/access