How do I access an element reference from within my component?
// thingo.svelte
<div />
<script>
console.log(this.querySelector('div')) // ???
</script>
Hi,
You can use the bind:this={myElement} attribute on your DOM element, as stated here in the API documentation of Svelte.
Hope it helps.
Most helpful comment
Hi,
You can use the
bind:this={myElement}attribute on your DOM element, as stated here in the API documentation of Svelte.Hope it helps.