Не работает калькулятор через кнопки
При ручном вводе данных всё хорошо. А через подменные кнопки input type="number"
+- не считает.
var calculator = new Vue({
el: '#calculator',
data: {
visota: '0.3',
dlina: '10',
shirina: '10',
length: '60',
rate: '5',
calcPayment: ''
},
computed: {
calcPloshad: function(e){
var ploshad = this.dlina * this.shirina;
return currencyFormat(ploshad);
},
calcObiym: function(e){
// var ploshad = this.dlina * this.shirina;
var obiym = this.dlina * this.shirina * this.visota;
return currencyFormat(obiym);
}
}
});
function currencyFormat (num) {
return num.toFixed(0).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")
}
* {
box-sizing: border-box;
}
html {
font-family: "proxima-nova", "Helvetica Neue",Helvetica,Arial,sans-serif;
-webkit-font-smoothing: antialiased;
}
body {
background: #999;
height: 100vh;
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
padding-top: 3px;
transition: all 0.3s ease-in;
}
.container {
max-width: 480px;
margin: 0 auto;
background-color: #fff;
padding: 0 64px;
box-shadow: 2px 2px 96px #111;
border-radius: 8px;
transition: all 0.3s ease-in;
}
label {
display: inline-block;
width: 25%;
min-width: 128px;
font-weight: bold;
}
input, select {
display: inline-block;
background-color: #fff;
color: #888;
border: 2px solid #888;
border-radius: 2px;
width: 100%;
font-size: 24px;
&:focus {
background-color: #fff;
color: #3200ff;
border-color: #3200ff;
outline: 0;
}
}
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
.payment {
color: #000;
font-size: 20px;
text-align: left;
font-weight: bold;
transition: all 0.3s ease-in;
@media (max-width: 512px){
font-size: 40px;
transition: all 0.3s ease-in;
}
@media (max-width: 400px){
font-size: 32px;
transition: all 0.3s ease-in;
}
}
@media (max-height: 750px){
body {
height: 100%;
}
}
.cont {
position: relative;
}
#calculator form {
position: relative;
}
#calculator input {
text-align: center;
}
#calculator .number-minus {
position: absolute;
left: 0;
bottom: 0;
width: 40px;
padding: 0;
display: block;
text-align: center;
border: none;
border-right: 1px solid #ddd;
font-size: 30px;
font-weight: 600;
background: transparent;
height: 34px;
}
#calculator .number-plus {
position: absolute;
right: 0;
bottom: 0;
width: 40px;
padding: 0;
display: block;
text-align: center;
border: none;
border-left: 1px solid #ddd;
font-size: 30px;
font-weight: 600;
background: transparent;
height: 34px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.10/vue.js"></script>
<div id="calculator">
<div class="container">
<form action="">
<div class="cont">
<label for="visota">Высота</label>
<button class="number-minus" type="button">-</button>
<input type="number" step="0.1" name="visota" class="visota" v-model.number="visota">
<button class="number-plus" type="button">+</button>
</div>
<div class="cont">
<label for="dlina">Длина</label>
<button class="number-minus" type="button">-</button>
<input type="number" step="0.5" name="dlina" class="dlina quantity-num" v-model.number="dlina">
<button class="number-plus" type="button">+</button>
</div>
<div class="cont">
<label for="shirina">Ширина</label>
<button class="number-minus" type="button">-</button>
<input type="number" step="0.5" name="shirina" class="shirina" v-model.number="shirina"/>
<button class="number-plus" type="button">+</button>
</div>
</form>
<div class="payment">Площадь плиты: {{ calcPloshad }} м<sup>2</sup></div>
<div class="payment">Объем бетона: {{ calcObiym }} м<sup>3</sup></div>
</div>
</div>