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-component-object-in-external-callback

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!