Skip to content

Commit 177ae8a

Browse files
authored
VueJs Computed Properties
VueJs Computed Properties
1 parent c51f5a6 commit 177ae8a

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

Diff for: video-11.html

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<html>
2+
<head>
3+
<script src="vue.js"></script>
4+
</head>
5+
6+
<body>
7+
8+
<div id="my-app">
9+
10+
<input type="text" v-model="maths" placeholder="Maths marks">
11+
<input type="text" v-model="science" placeholder="Science marks">
12+
<input type="text" v-model="english" placeholder="English marks">
13+
14+
<h3>Total Marks: {{ totalSubjectMarks }}</h3>
15+
16+
17+
{{ runme() }}
18+
19+
<br/><br/>
20+
21+
<input type="text" v-model="meter" placeholder="Enter length in meter">
22+
23+
<h4>Length in cm : {{ convertToCentimeter }}</h4>
24+
25+
<br/>
26+
<br/>
27+
<input type="text" placeholder="Enter First Name" v-model="firstname">
28+
<input type="text" placeholder="Enter Last Name" v-model="lastname">
29+
30+
<h4>Full name: {{ getFullName }}</h4>
31+
32+
</div>
33+
34+
<script src="video-11.js"></script>
35+
</body>
36+
</html>

Diff for: video-11.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
var myapp = new Vue({
2+
el:"#my-app",
3+
data:{
4+
firstname: "",
5+
lastname: "",
6+
meter:"",
7+
maths:0,
8+
science: 0,
9+
english: 0
10+
},
11+
methods:{
12+
runme: function(){
13+
console.log("This is first method");
14+
return "I am method"
15+
}
16+
},
17+
computed:{
18+
getFullName: function(){
19+
return this.firstname+" "+this.lastname;
20+
},
21+
convertToCentimeter: function(){
22+
return this.meter*100;// 1m = 100cm
23+
},
24+
totalSubjectMarks: function(){
25+
return parseInt(this.maths) + parseInt(this.english) + parseInt(this.science);
26+
}
27+
}
28+
});

0 commit comments

Comments
 (0)