Answer the question
In order to leave comments, you need to log in
How to get all item data from select?
Good day!
I am writing a small calculator on vue
. For example, I get the currency from the back in the currencies_data array. I go
through and output through select
<select class="form-control" v-model="price_curren">
<option v-for="curren in currencies_data"
:key="curren.code"
class="valuta_name"
:value="curren.value"
>
{{curren.title}}
</option>
</select>
calcSum(){
let res = this.price_curren * (this.price_site + this.price_servises)
return parseFloat( res.toFixed(1)) // вот здесь нужно название валюты curren.code
}
Answer the question
In order to leave comments, you need to log in
Set :value="curren" and get whatever you want out of it
Example https://jsfiddle.net/groog/L63yk01u/4/
<select class="form-control" v-model="price_curren">
<option v-for="curren in currencies_data"
:key="curren.code"
class="valuta_name"
:value="curren"
>
{{curren.title}}
</option>
</select>
calcSum(){
let res = this.price_curren * (this.price_site + this.price_servises)
return parseFloat( res.toFixed(1)) + this.price_curren.code
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question