Vue-select: Use Vi18n in v-select to get the localization value

Created on 30 Mar 2020  路  10Comments  路  Source: sagalbot/vue-select

<template >
<v-select 
searchable="" 
:dir="$vs.rtl ? 'rtl' : 'ltr'" 
:options="AccountStatusJson"
v-model="Model.AccountStatus"  
label="Code"
class="mt-5 w-full">
<template v-slot:option="option">
<span>{{ $t(option.Code) }}</span>
</template>
</v-select>
</template> 


sss

I have this example above
i get Values from JSON file and in the span i get the values from Vi18n depends on the code, but in the select (when i select any of them ) i cant print the value in the Span

up there in label="Code" it print the code in the JSON and if i put Value it print the Value

but i cant use ($t) in it to get the value from i18n or use the value in the span as i get it from the vi18n

Most helpful comment

Thanks for the reproductin! You can solve this with getOptionLabel .

https://vue-select.org/api/props.html#getoptionlabel

<v-select :options="options" :get-option-label="option => $t(option.Code)"></v-select>

https://codepen.io/sagalbot/pen/jOPRPQM?editors=1010

All 10 comments

<v-select>
   <template v-slot:selected-option="option">
        {{ $t(option.Code) }}
   </template>
</v-select>

鈽濓笍 that should be what you're looking for.

value doesnt update...
if i choose on and then choose another one it doesn't change

Can you post a reproduction link? Really hard to debug without one.

how to do this ... ?
can we do it trough team viewer ?

Could you make a simple reproduction at https://codepen.io/?

after first value selected i cant change it till i press on clear selected
and value doesnt appear in dropdown

Thanks for the reproductin! You can solve this with getOptionLabel .

https://vue-select.org/api/props.html#getoptionlabel

<v-select :options="options" :get-option-label="option => $t(option.Code)"></v-select>

https://codepen.io/sagalbot/pen/jOPRPQM?editors=1010

Thx alot, i will try it tomorrow.... <3

Thanks for the reproductin! You can solve this with getOptionLabel .

https://vue-select.org/api/props.html#getoptionlabel

<v-select :options="options" :get-option-label="option => $t(option.Code)"></v-select>

https://codepen.io/sagalbot/pen/jOPRPQM?editors=1010

You save my day sir! THANK YOU! 馃槏

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jluterek picture jluterek  路  3Comments

NexoraSolutions picture NexoraSolutions  路  3Comments

FrozenIce0617 picture FrozenIce0617  路  3Comments

lau-a picture lau-a  路  3Comments

rudykaze picture rudykaze  路  3Comments