1 Star 0 Fork 1

颜箴 / Vue

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0.16简易计算器.html 1.71 KB
一键复制 编辑 原始数据 按行查看 历史
颜箴 提交于 2019-03-12 22:13 . ‘‘‘憨憨的练习’
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div class="app">
<input type="text" v-model="n1">
<select v-model="opt">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
<input type="text" v-model="n2">
<input type="button" value="=" @click='calc'>
<input type="text" v-model='ads'>
</div>
<script src="./node_modules/_vue@2.5.22@vue/dist/vue.js"></script>
<script>
var vm = new Vue({
el: '.app',
data: {
n1: 0,
n2: 0,
ads: 0,
opt: '+'
},
methods: {
calc() {
switch (this.opt) {
case '+':
this.ads = this.n1 + this.n2
break;
case '-':
this.ads = this.n1 - this.n2
break;
case '*':
this.ads = this.n1 * this.n2
break;
case '/':
this.ads = this.n1 / this.n2
break;
}
// var codeStr = 'parseInt(this.n1)'+this.opt+'parseInt(this.n2)'
// this.ads = eval(codeStr)
}
}
})
</script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/twogouzi/Vue.git
git@gitee.com:twogouzi/Vue.git
twogouzi
Vue
Vue
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891