Sveltekit: Create component dynamically

PHOTO EMBED

Thu Mar 07 2024 01:42:31 GMT+0000 (Coordinated Universal Time)

Saved by @marcopinero #javascript #sveltekit

/* +page.svelte **/

<script>
    import Component2 from "./Component2.svelte";
    
    function abc() {
    	const element = new Component2({
    		target: document.querySelector('#abc')
    	})
    }
</script>

<div id="abc" use:abc>dsaads</div>

/* Component2.svelte **/

<script>
  export let params;
</script>
<div>
	<table>
		<tr>
			<td>dsadasads</td>
		</tr>
	</table>
</div>
content_copyCOPY

Create element dynamically part 1