This content originally appeared on CodeSource.io and was authored by Jatin Hemnani
In Svelte binding works differently and it’s two-way binding. In Svelte you don’t need any function or method to handle the input event as we do in React.
<script>
let name=''
</script>
<input type=text bind:value={name} placeholder="Enter Name" />
<h2>
Your Name is {name}
</h2>
Here we have a variable as name with an empty string and in HTML we have <input> with bind of the variable name and that’s it. You have now successfully bind the value to the input.
Result Of Above Code
1.
The post Bind Value In Svelte – Code Example appeared first on CodeSource.io.
This content originally appeared on CodeSource.io and was authored by Jatin Hemnani
Jatin Hemnani | Sciencx (2021-02-18T12:39:50+00:00) Bind Value In Svelte – Code Example. Retrieved from https://www.scien.cx/2021/02/18/bind-value-in-svelte-code-example/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.