-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path7Template.txt
188 lines (165 loc) · 6.32 KB
/
7Template.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
Template in Vue Js
- what is template
- Display normal property
- Make button click
- constant tag value
- operators
- add html as property
- Disable Button
1) How to display normal property?
- src/components/Home.vue:
<template>
<div>
<h1>Template in Vue Js</h1>
<h3>{{name}}</h3>
<h3>{{a+b}}}</h3>
</div>
</template>
<script>
export default {
name: 'Home',
data(){
return{
name: "Anil",
a=10,
b=20
}
}
}
</script>
2) How to make button click?
- src/components/Home.vue:
<template>
<div>
<h1>Template in Vue Js</h1>
<h3 v-once>{{name}}</h3> // v-once
<h3>{{name}}</h3>
<button v-on:click="updateText">Click Me</button> // v-on:click="updateText" method
</div>
</template>
<script>
export default {
name: 'Home',
data(){
return{
name: "Anil",
}
},
methods:{ // define method (updateText)
updateText(){
this.name = "John"
}
}
}
</script>
3) How to use normal Operators?
- src/components/Home.vue:
<template>
<div>
<h1>Template in Vue Js</h1>
<h3 v-once>{{name}}</h3>
<h3>{{name}}</h3>
<h3>{{ok?"YES":"NO"}}</h3> // define operators
<button v-on:click="updateText">Click Me</button>
</div>
</template>
<script>
export default {
name: 'Home',
data(){
return{
name: "Anil",
ok: true, // If ok is true then show YES, If ok is false then show NO
}
},
methods:{
updateText(){
this.name = "John"
}
}
}
</script>
4) How to use normal Operators with button click?
- src/components/Home.vue:
<template>
<div>
<h1>Template in Vue Js</h1>
<h3 v-once>{{name}}</h3>
<h3>{{name}}</h3>
<h3>{{ok?"YES":"NO"}}</h3> // define operators
<button v-on:click="updateText">Click Me</button>
</div>
</template>
<script>
export default {
name: 'Home',
data(){
return{
name: "Anil",
ok: true,
}
},
methods:{
updateText(){
this.ok = !this.ok; // If I click button then show YES and again I click button then show NO
}
}
}
</script>
5) How to add html as property?
- src/components/Home.vue:
<template>
<div>
<p v-html="rowHtml"></p> // that html print here using v-html="rowHtml"
<h3 v-once>{{name}}</h3>
<h3>{{name}}</h3>
<h3>{{ok?"YES":"NO"}}</h3>
<button v-on:click="updateText">Click Me</button>
</div>
</template>
<script>
export default {
name: 'Home',
data(){
return{
name: "Anil",
ok: true,
rowHtml: "<h1>Template in Vue Js</h1>" // html as a property
}
},
methods:{
updateText(){
this.ok = !this.ok;
}
}
}
</script>
6) How to disable button?
- src/components/Home.vue:
<template>
<div>
<p v-html="rowHtml"></p>
<h3 v-once>{{name}}</h3>
<h3>{{name}}</h3>
<h3>{{ok?"YES":"NO"}}</h3>
<button v-bind:disable="disableBtn" v-on:click="updateText">Click Me</button> // define property v-bind:disable="disableBtn"
</div>
</template>
<script>
export default {
name: 'Home',
data(){
return{
name: "Anil",
ok: true,
rowHtml: "<h1>Template in Vue Js</h1>",
disableBtn: true // Disable button property // true=disable and false=enable
}
},
methods:{
updateText(){
this.ok = !this.ok;
}
}
}
</script>