File tree 4 files changed +18
-55
lines changed
content/tutorial/01-svelte/06-bindings
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:
10
10
11
11
``` svelte
12
12
/// file: App.svelte
13
- <input bind:value={name}>
13
+ <input +++ bind:+++ value={name}>
14
14
```
15
15
16
16
This 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:
8
8
9
9
``` svelte
10
10
/// 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>
13
20
```
Original file line number Diff line number Diff line change 4
4
</script >
5
5
6
6
<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" />
20
9
</label >
21
10
22
11
<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" />
36
14
</label >
37
15
38
16
<p >{a } + {b } = {a + b }</p >
Original file line number Diff line number Diff line change 4
4
</script >
5
5
6
6
<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" />
20
9
</label >
21
10
22
11
<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" />
36
14
</label >
37
15
38
16
<p >{a } + {b } = {a + b }</p >
You can’t perform that action at this time.
0 commit comments