复制代码
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<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <div id="app"> <input type="text" v-model="num1"> <select v-model="fuHao"> <option value="0">+</option> <option value="1">-</option> <option value="2">*</option> <option value="3">/</option> </select> <input type="text" v-model="num2"> <button v-on:click="jiSuan">=</button> <span id="span">{{ result }}</span> </div> <script src="node_modules/vue/dist/vue.js"></script> <script> var app = new Vue({ el: '#app', data: { num1: 0, fuHao: 1, num2: 0, result: 0 }, methods: { jiSuan: function () { if(this.fuHao == 0) { this.result = Number(this.num1) + Number(this.num2) } else if (this.fuHao == 1) { this.result = Number(this.num1) - Number(this.num2) }else if (this.fuHao == 2) { this.result = Number(this.num1) * Number(this.num2) }else if (this.fuHao == 3) { this.result = Number(this.num1) / Number(this.num2) } } } }) </script> </body> </html>
最后
以上就是激情咖啡豆最近收集整理的关于vue-加减乘除计算器案例的全部内容,更多相关vue-加减乘除计算器案例内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复