A
A
Alianos2021-04-25 03:43:05
Vue.js
Alianos, 2021-04-25 03:43:05

How to save images from vue-select.org options?

Hello, due to the need for a beautiful-animated select-e language, I use vue-select.org, however, as far as I understand, svg will have to be stored in data in it, that is, I will succeed

data: {
    options: [
      {
          title: 'Read the Docs',
          svg: '<svg>...</svg>',
        },
]
}

How good is this approach, wouldn't it be better to describe options in html and pictures in divs (as in a normal select)?
How would you do your implementation of the select on divs?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lavezzi1, 2021-04-25
@lavezzi1

This is bad practice. The most optimal option is to use the slot option as specified in the api:

<template>
  <v-select :options="books" label="title">
    <template #option="{ title, author }">
      <h3 style="margin: 0">{{ title }}</h3>
      <em>{{ author.firstName }} {{ author.lastName }}</em>
    </template>
  </v-select>
</template>

And here it is already to sort out which picture should be rendered.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question