<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
<input type="text" size="20" v-model="num1" @change="jisuan">
<select v-model="fuhao" @change="jisuan">
<option value="jia">+</option>
<option value="jian">-</option>
<option value="cheng">*</option>
<option value="chu">/</option>
</select>
<input type="text" size="20" v-model="num2" @change="jisuan">
=
<input type="text" size="20" v-model="result">
</div>
<script src="js/vuejs-2.5.16.js"></script>
<script>
new Vue({
el: "#app",
data: {
num1:0,
num2:0,
result:0,
fuhao: "jia"
},
methods: {
jisuan() {
switch (this.fuhao) {
case "jia":
this.result = this.num1 / 1 + this.num2 / 1;
break;
case "jian":
this.result = this.num1 / 1 - this.num2 / 1;
break;
case "cheng":
this.result = this.num1 / 1 * this.num2 / 1;
break;
case "chu":
this.result = this.num1 / 1 / this.num2 / 1;
break;
}
}
}
})
</script>
</body>
</html>