Selected item slot for Select component
See original GitHub issueThis function solves the problem
It would be great to have selected-item
(or any other name) slot to improve customization of selected value.
Expected API
Also instead of render-label
property, it would be great to have scoped slot as I think it is more suitable for Vue. Having prop to customize render is kind of React thing.
<template>
<n-select :options="options" >
<template #selected-item="{ item }">
{{item.label}} - {{item.value}}
</template>
<template #option="{ item }">
This is {{item.label}}
</template>
</n-select>
</template>
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
Selected-item slot - Quasar Playground - CodePen
https://quasar.dev/vue-components/select#Example--Selected-item-slot. 4. -->. 5. <div id="q-app">. 6. <div class="q-pa-md" style="max-width: 300px">.
Read more >Get value of clicked item in Vuetify multiple select component
So essentially all the items are selected when the component is mounted. Once the user clicks on an item from the list, I...
Read more >Select component — Vuetify
The selection slot can be used to customize the way selected values are shown in the input. This is great when you want...
Read more >Selected Item Slot help - Redstone Discussion and Mechanisms
I wanted to testfor if the player has the selected item slot 1-9, and if the player is holding a map with a...
Read more >[docs] q-select with v-slot:selected-item #4739 - GitHub
In that case, you have to add option-value="id" or something similar to your q-select , so that internal :key="opt.value" binding works ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks! I know many people perfer slot API (if it is typed, I would too). However now the typed slot rfc is still pending (the same for generic types), I think it’s risky to implement it before the rfc is merged. If there’re some changes, it will cost a lot to change all the related codes.
https://github.com/vuejs/rfcs/pull/192
I mean it doesn’t mix too much logic (with complex slot props) in it. Since Vue doesn’t has good typescript support for slots. I think it is dangerous to rely too much on slots now (nor API and implementation may break a lot if vue change its API).
However the feature will be provided (not by slot api). It’s necessary.