I was trying to create an Input
component for my project. I want to set type attribute dyamically on input
element
But when i set type attribute dynamically on input
i get error saying
'type' attribute cannot be dynamic if input uses two-way binding
So is there any workaround for this such that i can set type attribute dynamically without loosing two way binding
Input.svelte
<script>
export let placeholder = "";
export let label = "";
export let description = "";
export let value = "";
export let type = "text";
</script>
<div class="container">
<label>{label}</label>
<input {type} bind:value {placeholder} />
<p>{description}</p>
</div>
console.log{ value: new FormData(form).get('inputname') }
inside<form on:submit>
event. Thanks for this wonderful Svelte framework btw! – Weide