Answer the question
In order to leave comments, you need to log in
Vue.js tile and border area coverage calculator?
Good afternoon.
I'm learning Vue.js and got a little bit of cognitive dissonance.
A simple calculator for calculating the cost by price and quantity, no problem.
But then ...
I want to make a calculator from a bunch of inputs, in which.
1. There is a list to choose from, let's say building tiles with Value and Data-value parameters.
Using jquery I would just get the data-value $('select').attr('data-value') and not bother.
<select>
<option disabled value="">Выберите один из вариантов</option>
<option value="10" data-value="15">А-10</option>
<option value="20" data-value="25">А-20</option>
<option value="30" data-value="35">А-30</option>
<option value="40" data-value="45">А-40</option>
</select>
<input
type="number"
placeholder="Ширина"
name="width"
v-model="width"
v-on:input="area = width * lenght">
<input
type="number"
placeholder="Длина"
name="lenght"
v-model="lenght"
v-on:input="area = width * lenght">
<br>
<input
type="number"
placeholder="Площадь"
name="area"
v-model="area"
v-on:input="cost = area / count">
<span>{{ text1 }}{{ area }}</span><br>
<span>{{ text2 }}{{ cost }}</span>
<button v-on:click="">Расчитать</button>
var app = new Vue({
el: '#app_calc',
data: {
item: '',
text1: 'Площадь: ',
text2: 'Колличество: ',
width: 10,
lenght: 10,
area: 0,
count: 0,
cost: 0
},
methods:{
deem: function (){
}
}
})
Answer the question
In order to leave comments, you need to log in
1. You can even dynamically create all lists)
https://ru.vuejs.org/v2/guide/forms.html#%D0%92%D1...
2. See if something has changed and recalculate everything
https:/ /en.vuejs.org/v2/api/#watch
ps But it's better to write it in computed, then it will track everything itself
As an example:
https://codepen.io/andreysh/pen/ZwXPOj
Yes, I'm looking at similar questions here, and I realized that I went a little in the wrong direction.
But so far I'm still lost =_=
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question