mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-10 18:38:22 +00:00
Add Pillbar modelValue
This commit is contained in:
parent
2c02451da7
commit
2fb089ba73
1 changed files with 5 additions and 3 deletions
|
@ -6,18 +6,20 @@ const props = defineModel<{
|
|||
icon: Component,
|
||||
selected: boolean,
|
||||
}[],
|
||||
modelValue: number,
|
||||
}>();
|
||||
let { options } = $(props);
|
||||
let { options, modelValue } = $(props);
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'selectionChanged'): void
|
||||
}>();
|
||||
|
||||
function select(option: any) {
|
||||
function select(option: any, index: number) {
|
||||
for(let opt of options) {
|
||||
opt.selected = false;
|
||||
}
|
||||
option.selected = true;
|
||||
modelValue = index;
|
||||
emit('selectionChanged');
|
||||
console.debug("selected", options);
|
||||
}
|
||||
|
@ -26,7 +28,7 @@ function select(option: any) {
|
|||
|
||||
<template>
|
||||
<div>
|
||||
<button class="option" v-for="(option, index) in options" :key="index" :class="{selected:option.selected}" @click="select(option)">
|
||||
<button class="option" v-for="(option, index) in options" :key="index" :class="{selected:option.selected}" @click="select(option, index)">
|
||||
<i class="material-icons" v-if="option.icon">{{ option.icon }}</i>
|
||||
{{ option.name }}
|
||||
</button>
|
||||
|
|
Loading…
Add table
Reference in a new issue