Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

show raw html in vuetify v-select

My question seems to be easy, but couldn't figure this out.

I have this

  <VSelect :items="common.users.options" ></VSelect> which just shows me select and its options. 

common.users.options is something like this:

[
    { value:".25",text:"&#188; hour" },
    { value:".5",text:"&#189; hour" },
]

The bad thing is that VSelect shows me &#188 and &#189 as you see, without transforming it into fraction html. https://www.codetable.net/decimal/188

how do I show fraction into vselect option's without just plain &#188 ?

like image 696
Nika Kurashvili Avatar asked Oct 28 '25 10:10

Nika Kurashvili


1 Answers

Override the item and selection slots, and use v-html.

<v-select :items='item'>
 <template v-slot:item='{item}'> <div v-html='item.text'/> </template>
 <template v-slot:selection='{item}'> <div v-html='item.text'/> </template>
</v-select>

Of course you can use something fancier than a div.

If you want more succinct code, you can also put a div directly in a slot using slot and slot-scope instead of v-slot.

 <div slot='item' slot-scope='{item}' v-html='item.text'/>

Newer Syntax

<template #item='{item}'>
  <div v-html='item.text' />
</template>
like image 79
Steven Spungin Avatar answered Oct 30 '25 12:10

Steven Spungin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!