File tree Expand file tree Collapse file tree 1 file changed +20
-18
lines changed Expand file tree Collapse file tree 1 file changed +20
-18
lines changed Original file line number Diff line number Diff line change 5
5
< meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6
6
< meta http-equiv ="X-UA-Compatible " content ="ie=edge ">
7
7
< title > 뷰 기초 익히기</ title >
8
+ < style >
9
+ .red {
10
+ color : red;
11
+ }
12
+
13
+ .font-bold {
14
+ font-weight : bold;
15
+ }
16
+ </ style >
8
17
< script src ="https://cdn.jsdelivr.net/npm/vue/dist/vue.js "> </ script >
9
18
</ head >
10
19
< body >
11
20
< div id ="app ">
12
- {{ message }}< br >
13
- < button @click ="changeMessage "> Click</ button > < br >
14
- {{ updated }}
21
+ < div :style ="{ color: red, fontSize: size} "> Hello</ div >
22
+
23
+ < div :class ="{ red: isRed, 'font-bold': isBold} "> Hello</ div >
24
+ < button @click ="update "> Click</ button >
15
25
</ div >
16
26
< script >
17
27
new Vue ( {
18
28
el : '#app' ,
19
29
data : {
20
- message : '헬로우' ,
21
- updated : '아니요'
30
+ isRed : false ,
31
+ isBold : false ,
32
+ red : 'red' ,
33
+ size : '30px'
22
34
} ,
23
35
methods : {
24
- changeMessage ( ) {
25
- this . message = '코지코더' ;
36
+ update ( ) {
37
+ this . isRed = ! this . isRed ;
38
+ this . isBold = ! this . isBold ;
26
39
}
27
40
} ,
28
- computed : {
29
- reversedMessage ( ) {
30
- return this . message . split ( '' ) . reverse ( ) . join ( '' )
31
- }
32
- } ,
33
- watch : {
34
- message ( newVal , oldVal ) {
35
- console . log ( newVal , oldVal ) ;
36
- this . updated = '네' ;
37
- }
38
- }
39
41
} )
40
42
</ script >
41
43
</ body >
You can’t perform that action at this time.
0 commit comments