File tree Expand file tree Collapse file tree 4 files changed +18
-55
lines changed
content/tutorial/01-svelte/06-bindings Expand file tree Collapse file tree 4 files changed +18
-55
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ Instead, we can use the `bind:value` directive:
1010
1111``` svelte
1212/// file: App.svelte
13- <input bind:value={name}>
13+ <input +++ bind:+++ value={name}>
1414```
1515
1616This means that not only will changes to the value of ` name ` update the input value, but changes to the input value will update ` name ` .
Original file line number Diff line number Diff line change @@ -8,6 +8,13 @@ With `bind:value`, Svelte takes care of it for you:
88
99``` svelte
1010/// file: App.svelte
11- <input type=number bind:value={a} min=0 max=10>
12- <input type=range bind:value={a} min=0 max=10>
11+ <label>
12+ <input type="number" +++bind:+++value={a} min="0" max="10" />
13+ <input type="range" +++bind:+++value={a} min="0" max="10" />
14+ </label>
15+
16+ <label>
17+ <input type="number" +++bind:+++value={b} min="0" max="10" />
18+ <input type="range" +++bind:+++value={b} min="0" max="10" />
19+ </label>
1320```
Original file line number Diff line number Diff line change 44 </script >
55
66<label >
7- <input
8- type =" number"
9- value ={a }
10- min =" 0"
11- max =" 10"
12- />
13-
14- <input
15- type =" range"
16- value ={a }
17- min =" 0"
18- max =" 10"
19- />
7+ <input type ="number" value ={a } min =" 0" max =" 10" />
8+ <input type ="range" value ={a } min =" 0" max =" 10" />
209</label >
2110
2211<label >
23- <input
24- type =" number"
25- value ={b }
26- min =" 0"
27- max =" 10"
28- />
29-
30- <input
31- type =" range"
32- value ={b }
33- min =" 0"
34- max =" 10"
35- />
12+ <input type ="number" value ={b } min =" 0" max =" 10" />
13+ <input type ="range" value ={b } min =" 0" max =" 10" />
3614</label >
3715
3816<p >{a } + {b } = {a + b }</p >
Original file line number Diff line number Diff line change 44 </script >
55
66<label >
7- <input
8- type =" number"
9- bind:value ={a }
10- min =" 0"
11- max =" 10"
12- />
13-
14- <input
15- type =" range"
16- bind:value ={a }
17- min =" 0"
18- max =" 10"
19- />
7+ <input type ="number" bind:value ={a } min =" 0" max =" 10" />
8+ <input type ="range" bind:value ={a } min =" 0" max =" 10" />
209</label >
2110
2211<label >
23- <input
24- type =" number"
25- bind:value ={b }
26- min =" 0"
27- max =" 10"
28- />
29-
30- <input
31- type =" range"
32- bind:value ={b }
33- min =" 0"
34- max =" 10"
35- />
12+ <input type ="number" bind:value ={b } min =" 0" max =" 10" />
13+ <input type ="range" bind:value ={b } min =" 0" max =" 10" />
3614</label >
3715
3816<p >{a } + {b } = {a + b }</p >
You can’t perform that action at this time.
0 commit comments