console
var app = new Vue({
el: '#app',
data() {
return {
inp_1: '',
label_item: ['MC', 'MR', 'MS', 'M+', 'M-', '←', 'CE', 'C', '±', '√', 7, 8, 9, '/', '%', 4, 5, 6, '*', '∑', 1, 2, 3, '-', '', 0, '.', '+', '='],
one: '',
use: '',
two: '',
three: '',
}
},
methods: {
ceshi: function () {
var thisobj = this;
thisobj.inp_1 = '我点击了';
},
label_itP: function (label) {
var thisobj = this;
var number = parseInt(label);
if (!isNaN(number)) {
if (thisobj.use == '') {
thisobj.one += label;
} else {
thisobj.two += label;
}
}
else if (label == '+') {
console.log(label)
thisobj.use = label;
}
else if (label == '=') {
if (thisobj.one == '' || thisobj.use == '' || thisobj.two == '') {
console.log('异常!');
return;
}
if (thisobj.use == '+') {
thisobj.inp_1 = (parseInt(thisobj.one) + parseInt(thisobj.two));
return;
}else if(thisobj.use=='-'){
thisobj.inp_1 = (parseInt(thisobj.one) - parseInt(thisobj.two));
return;
}else if(thisobj.use=='*'){
thisobj.inp_1 = (parseInt(thisobj.one) * parseInt(thisobj.two));
return;
}else if(thisobj.use=='/'){
thisobj.inp_1 = (parseInt(thisobj.one) / parseInt(thisobj.two));
return;
}
thisobj.one='';
thisobj.two='';
thisobj.inp_1='';
}else if(label=='C'){
thisobj.one='';
thisobj.two='';
thisobj.three='';
thisobj.inp_1='';
return;
}
else if(label=='←'){
if(thisobj.two.length>0){
thisobj.two=thisobj.two.Substring(0,thisobj.two.Length-1)
}else if(thisobj.use.length>0){
thisobj.use=thisobj.use.Substring(0,thisobj.use.Length-1)
}else if(thisobj.one.length>0){
thisobj.one=thisobj.one.Substring(0,thisobj.one.Length-1)
}else if(thisobj.inp_1.length>0){
thisobj.inp_1=thisobj.one.Substring(0,thisobj.inp_1.Length-1)
}
return;
}
thisobj.inp_1 += label;
}
},
mounted: function () {
var thisobj = this;
}
});
<div id="app" class="items">
<div class="item-title">
<div class="title-one">
查看(V)
</div>
<div class="title-one">
编辑(E)
</div>
<div class="title-one">
帮助(H)
</div>
</div>
<div class="item-group">
<textarea type="text" class="inp" v-model="inp_1" disabled></textarea>
</div>
<div class="item-label">
<label :class="label=='='?'dengyu':label=='0'?'ling':''" v-for="label in label_item" v-on:click="label_itP(label)">{{label}}</label>
</div>
<div class="item-btn">
<input type="button" class="btn" value="点击" v-on:click="ceshi">
</div>
</div>
.items{
height: 500px;
width: 380px;
background: #f7f7f7;
border: 1px #000 solid;
border-radius: 5px;
}
.items .item-title{
flex: 1;
display: flex;
padding: 5px 10px 1px;
border-bottom: 1px #dddddd solid;
}
.items .title-one{
height: auto;
margin-right: 10px;
padding-right: 10px;
margin-bottom: 5px;
}
.items .item-group{
height: 100px;
width: 94%;
text-align: center;
}
.items .item-group textarea{
max-height: 100%;
height: calc( 100% - 25px );
width: calc( 100% - 25px );
margin: 10px;
border: 1px rgb(58, 57, 57) solid;
text-align: left;
resize: none;
vertical-align: bottom
}
.items .item-btn{
margin-left: 10px;
}
.items .item-btn .btn{
background: rgb(3, 7, 5);
width: 60px;
text-align: center;
color: #f4f4f4;
border: none;
border-radius: 5px;
height: 25px;
}
.items .item-btn .btn:hover{
background: rgb(32, 197, 40);
border: 1ps rgb(32, 197, 40) solid;
}
.item-label{
width: 90%;
height: 300px;
margin: 5px 10px;
}
.item-label label{
width: 60px;
height: 30px;
text-align: center;
float: left;
min-height: 30px;
max-height: 30px;
border: 1px #918d8d solid;
margin: 3px;
background: #ddd
}
.item-label .dengyu{
height: 6lm0px;
max-height: 60px;
}
.item-label .ling{
width: 128px;
}