D
D
Dauren S2020-02-19 20:44:33
Vue.js
Dauren S, 2020-02-19 20:44:33

Substitute language variable in vue.js iteration?

There is such an output in the template

<option   v-for="dish in  menu.dishes[1][0]" :value="dish.id"   v-bind:key="dish.id">{{dish.title_ru}}</option>


export default {

  data(){
    return {
      menu:{
        dishes:  '',
        selectedmenu:  '',
      },
      dates: '',
      personal:'',
      lang:'',
    }
  }

I will get the lang variable from the api.
{{dish.title_ru}} wanted instead of ru to substitute the value from the API for example en. How can I put a variable there?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-02-19
@dauren101

{{ dish[`title_${lang}`] }}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question