Created
January 10, 2017 04:28
-
-
Save anonymous/7fa6b3bd1ace4cef990523b792063322 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/vameribame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div id="app" class="container"> | |
<h2>Type 2 numbers and chose ooperation</h2> | |
<form class="form-inline"> | |
<input v-model.number="a" class="form-control"> | |
<select v-model="operator" class="form-control"> | |
<option>+</option> | |
<option>-</option> | |
<option>*</option> | |
<option>/</option> | |
</select> | |
<input v-model.number="b" class="form-control"> | |
<button type="submit" @click="calculate" class="btn btn-primary">Calculate</button> | |
</form> | |
<h2>Result: {{ a }} {{ operator }} {{ b }} = {{ c }} </h2> | |
<pre>{{ $data }}</pre> | |
</div> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.3/vue.js"></script> | |
<script id="jsbin-javascript"> | |
new Vue({ | |
el: '#app', | |
data: { | |
a: 1, | |
b: 2, | |
c: null, | |
operator: "+" | |
}, | |
methods: { | |
calculate(e) { | |
e.preventDefault() | |
switch (this.operator) { | |
case "+": | |
this.c = this.a + this.b | |
break; | |
case "-": | |
this.c = this.a - this.b | |
break; | |
case "*": | |
this.c = this.a * this.b | |
break; | |
case "/": | |
this.c = this.a / this.b | |
break; | |
} | |
} | |
} | |
}); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">new Vue({ | |
el: '#app', | |
data: { | |
a: 1, | |
b: 2, | |
c: null, | |
operator: "+" | |
}, | |
methods: { | |
calculate(e) { | |
e.preventDefault() | |
switch (this.operator) { | |
case "+": | |
this.c = this.a + this.b | |
break; | |
case "-": | |
this.c = this.a - this.b | |
break; | |
case "*": | |
this.c = this.a * this.b | |
break; | |
case "/": | |
this.c = this.a / this.b | |
break; | |
} | |
} | |
} | |
});</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Vue({ | |
el: '#app', | |
data: { | |
a: 1, | |
b: 2, | |
c: null, | |
operator: "+" | |
}, | |
methods: { | |
calculate(e) { | |
e.preventDefault() | |
switch (this.operator) { | |
case "+": | |
this.c = this.a + this.b | |
break; | |
case "-": | |
this.c = this.a - this.b | |
break; | |
case "*": | |
this.c = this.a * this.b | |
break; | |
case "/": | |
this.c = this.a / this.b | |
break; | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment