File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
For now, our component renders some static data. Try to change a number 3 in the code to something different to see how the rendered result changes.
4
4
5
- Let's add some dynamic data. Within component ` data ` return statement, add a property ` colorsNumber ` .
5
+ How to make it dynamic? We need to create our first _ reactive_ property ` colorsNumber `
6
+
7
+ <div class =" options-api " >
8
+
9
+ ``` js
10
+ data () {
11
+ return {
12
+ colorsNumber: 3
13
+ }
14
+ }
15
+ ```
16
+
17
+ </div >
18
+
19
+ <div class =" composition-api " >
20
+
21
+ ``` js
22
+ import { ref } from ' vue'
23
+ const colorsNumber = ref (3 )
24
+ ```
25
+
26
+ </div >
27
+
28
+ Now, we can use it in our template instead of a static number:
29
+
30
+ ``` html
31
+ <h2 >Number of colors: {{ colorsNumber }}</h2 >
32
+ ```
33
+
34
+ Try to change the ` colorsNumber ` and check how it immediately updates the rendered HTML.
You can’t perform that action at this time.
0 commit comments