File tree Expand file tree Collapse file tree 3 files changed +15
-29
lines changed Expand file tree Collapse file tree 3 files changed +15
-29
lines changed Original file line number Diff line number Diff line change 1
1
new Vue ( {
2
2
el : '#vue-app' ,
3
3
data : {
4
- available : false ,
5
- nearby : false
4
+ error : false ,
5
+ success : false
6
6
} ,
7
7
methods : {
8
8
9
9
} ,
10
10
computed : {
11
- compClasses : function ( ) {
12
- return {
13
- available : this . available ,
14
- nearby : this . nearby ,
15
- }
16
- }
11
+
17
12
}
18
13
} ) ;
Original file line number Diff line number Diff line change 8
8
</ head >
9
9
< body >
10
10
< div id ="vue-app ">
11
- < h1 > Dynamic CSS</ h1 >
12
- <!-- <h2>Example 1</h2>
13
- <div v-on:click="available = !available" v-bind:class="{available: available}">
14
- <span>Ryu</span>
15
- </div> -->
16
- < h2 > Example 2</ h2 >
17
- < button v-on:click ="nearby = !nearby "> Toggle nearby</ button >
18
- < button v-on:click ="available = !available "> Toggle available</ button >
19
- < div v-bind:class ="compClasses ">
20
- < span > Ryu</ span >
21
- </ div >
11
+ < h1 > Conditionals</ h1 >
12
+ < button v-on:click ="error = !error "> Toggle error</ button >
13
+ < button v-on:click ="success = !success "> Toggle success</ button >
14
+ <!-- <p v-if="error" class="error">There has been an error</p>
15
+ <p v-if="success" class="success">Whooo, success :)</p> -->
16
+ < p v-show ="error " class ="error "> There has been an error</ p >
17
+ < p v-show ="success " class ="success "> Whooo, success :)</ p >
22
18
</ div >
23
19
</ body >
24
20
Original file line number Diff line number Diff line change 1
- span {
1
+ . error {
2
2
background : red;
3
- display : inline-block;
4
3
padding : 10px ;
5
- color : # fff ;
6
- margin : 10px 0 ;
4
+ color : white;
7
5
}
8
6
9
- .available span {
7
+ .success {
10
8
background : green;
11
- }
12
-
13
- .nearby span : after {
14
- content : "nearby" ;
15
- margin-left : 10px ;
9
+ padding : 10px ;
10
+ color : white;
16
11
}
You can’t perform that action at this time.
0 commit comments