A
A
ashfedor2021-03-11 13:39:07
Vue.js
ashfedor, 2021-03-11 13:39:07

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>

Thus, in v-model I get the exchange rate by which I multiply the result.
For an example, in a computer, I create
calcSum(){
        let res = this.price_curren * (this.price_site + this.price_servises)
        return parseFloat( res.toFixed(1)) // вот здесь нужно название валюты curren.code
      }

And how can I get the currency code curren.code or the name curren.title to display as a result?
I understand that the answer is simple and close, but there is not enough knowledge in vue
This is the first working project

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Daniil Popov, 2021-03-11
@ashfedor

Set :value="curren" and get whatever you want out of it
Example https://jsfiddle.net/groog/L63yk01u/4/

E
Erl, 2021-03-11
@NooBiToo

<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 question

Ask a Question

731 491 924 answers to any question