mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-11 19:08:20 +00:00
Make PillBar Properly work with ModelValue
This commit is contained in:
parent
85c1693664
commit
356dcd77cf
1 changed files with 5 additions and 13 deletions
|
@ -10,25 +10,17 @@ const props = defineModel<{
|
||||||
}>();
|
}>();
|
||||||
let { options, modelValue } = $(props);
|
let { options, modelValue } = $(props);
|
||||||
|
|
||||||
const emit = defineEmits<{
|
onMounted(async() => {
|
||||||
(event: 'selectionChanged'): void
|
if (modelValue === undefined) {
|
||||||
}>();
|
modelValue = 0
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<button class="option" v-for="(option, index) in options" :key="index" :class="{selected:option.selected}" @click="select(option, index)">
|
<button class="option" v-for="(option, index) in options" :key="index" :class="{selected: modelValue == index}" @click="modelValue = index">
|
||||||
<i class="material-icons" v-if="option.icon">{{ option.icon }}</i>
|
<i class="material-icons" v-if="option.icon">{{ option.icon }}</i>
|
||||||
{{ option.name }}
|
{{ option.name }}
|
||||||
</button>
|
</button>
|
||||||
|
|
Loading…
Add table
Reference in a new issue