File tree Expand file tree Collapse file tree 4 files changed +350
-60
lines changed
packages/vue-template-compiler Expand file tree Collapse file tree 4 files changed +350
-60
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < meta charset ="utf-8 " />
5+ < title > DIFFERENT-TAG-VNODE-DIFF</ title >
6+ < script src ="../../dist/vue.js "> </ script >
7+ < style >
8+ .red {
9+ color : red;
10+ }
11+ </ style >
12+ </ head >
13+
14+ < body >
15+ < div id ="app ">
16+ < Child :has-changed ="hasChanged "> </ Child >
17+ < button @click ="change "> toggle</ button >
18+ </ div >
19+
20+ < script type ="text/x-template " id ="Child ">
21+
22+ < div v-if = "hasChanged" > Hello, Vue</ div >
23+ < p v - else >
24+ < span class = "red" > Hello, Jour</ span >
25+ < / p >
26+
27+ </ script >
28+
29+ < script >
30+ Vue . component ( 'Child' , {
31+ props : [ 'hasChanged' ] ,
32+
33+ template : '#Child'
34+ } ) ;
35+
36+ new Vue ( {
37+ el : '#app' ,
38+
39+ name : 'App' ,
40+
41+ Components : {
42+ Child
43+ } ,
44+
45+ data : function ( ) {
46+ return {
47+ hasChanged : true
48+ } ;
49+ } ,
50+
51+ methods : {
52+ change ( ) {
53+ this . hasChanged = ! this . hasChanged ;
54+ }
55+ }
56+ } )
57+ </ script >
58+ </ body >
59+ </ html >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < meta charset ="utf-8 " />
5+ < title > VNODE-DIFF</ title >
6+ < script src ="../../dist/vue.js "> </ script >
7+ </ head >
8+
9+ < body >
10+ < div id ="app ">
11+ < ul >
12+ < li v-for ="item of myArr " :key ="item.id ">
13+ {{ item.text }}
14+ </ li >
15+ </ ul >
16+ < button @click ="change "> toggle</ button >
17+ </ div >
18+ < script >
19+ new Vue ( {
20+ el : '#app' ,
21+
22+ data : function ( ) {
23+ return {
24+ myArr : [ {
25+ id : 1 ,
26+ text : 'a'
27+ } , {
28+ id : 2 ,
29+ text : 'b'
30+ } , {
31+ id : 3 ,
32+ text : 'c'
33+ } , {
34+ id : 4 ,
35+ text : 'd'
36+ } ]
37+ } ;
38+ } ,
39+
40+ methods : {
41+ change ( ) {
42+ this . myArr . splice ( 1 , 1 , {
43+ id : 5 ,
44+ text : 'e'
45+ } ) ;
46+
47+ this . myArr = this . myArr . reverse ( ) ;
48+ }
49+ }
50+ } )
51+ </ script >
52+ </ body >
53+ </ html >
You can’t perform that action at this time.
0 commit comments