File tree Expand file tree Collapse file tree 4 files changed +72
-0
lines changed Expand file tree Collapse file tree 4 files changed +72
-0
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
+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
6
+ < title > VueJS</ title >
7
+ < link rel ="stylesheet " href ="">
8
+ </ head >
9
+ < body >
10
+ < div id ="app ">
11
+ <!-- A diretiva v-model serve para fazer o two-way data-binding, ou seja,
12
+ setar o valor default do campo e no mesmo momento, quando houver alguma
13
+ mudança neste valor, realizar a atualização da propriedade dentro da
14
+ instância do Vue -->
15
+ < input type ="text " name ="name " id ="name " v-model ="name ">
16
+ </ div >
17
+
18
+ < script src ="../js/vue.js "> </ script >
19
+ < script src ="../js/exemplo5.js "> </ script >
20
+ </ body >
21
+ </ html >
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < meta charset ="utf-8 ">
5
+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
6
+ < title > VueJS</ title >
7
+ < link rel ="stylesheet " href ="">
8
+ </ head >
9
+ < body >
10
+ < div id ="app ">
11
+ < button v-on:click ="counter++ "> Increase</ button >
12
+ < button v-on:click ="counter-- "> Decrease</ button >
13
+ < button v-on:click ="secondCounter++ "> SecondCounter</ button >
14
+
15
+ < p > Counter: {{ counter }} | {{ secondCounter }} </ p >
16
+
17
+ <!-- Variáveis que estão dentro do "computed" são chamadas da mesma forma que o data. -->
18
+ < p > Result: {{ result() }} | {{ output }} </ p >
19
+ </ div >
20
+
21
+ < script src ="../js/vue.js "> </ script >
22
+ < script src ="../js/exemplo6.js "> </ script >
23
+ </ body >
24
+ </ html >
Original file line number Diff line number Diff line change
1
+ new Vue ( {
2
+ el : '#app' ,
3
+ data :{
4
+ name : 'Luiz'
5
+ }
6
+ } ) ;
Original file line number Diff line number Diff line change
1
+ new Vue ( {
2
+ el : '#app' ,
3
+ data :{
4
+ counter : 0 ,
5
+ secondCounter : 0
6
+ } ,
7
+ // O Computed armazena dados para serem usados em sua página assim como o data.
8
+ // A diferença é que aqui os dados são funções, e não dados estáticos.
9
+ computed : {
10
+ output : function ( ) {
11
+ console . log ( 'Computed' ) ;
12
+ return this . counter > 5 ? 'Greater than 5' : 'Smaller than 5' ;
13
+ }
14
+ } ,
15
+ methods : {
16
+ result : function ( ) {
17
+ console . log ( 'Method' ) ;
18
+ return this . counter > 5 ? 'Greater than 5' : 'Smaller than 5' ;
19
+ }
20
+ }
21
+ } ) ;
You can’t perform that action at this time.
0 commit comments