Suppose I have a reusable component called button.svelte
,
<script>
export let text = undefined
</script>
<button>{text}</button>
Now I reuse this component in another component like so,
<script>
import { onMount } from "svelte"
import Button from "./Button.svelte"
let button
onMount(() => {
console.log(button) // How do I print the html of the button element?
})
</script>
<Button text="Button" bind:this="{button}"></Button>
But button
of bind:this
doesn't seem to have the html of the button element. How do I get the html element of the button?
button.innerHTML
but showsundefined
– Culver