Improve MkRadios

This commit is contained in:
syuilo
2020-11-14 12:50:24 +09:00
parent ba65226460
commit 6c3417d9b5
2 changed files with 40 additions and 37 deletions

View File

@ -1,14 +1,5 @@
<template>
<div
class="novjtcto"
>
<div><slot></slot></div>
<MkRadio v-for="def in defs" v-model="value" :value="def.value" :key="def.value">{{ def.label }}</MkRadio>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { defineComponent, h } from 'vue';
import MkRadio from '@/components/ui/radio.vue';
export default defineComponent({
@ -32,6 +23,22 @@ export default defineComponent({
value() {
this.$emit('update:modelValue', this.value);
}
},
render() {
const label = this.$slots.desc();
const options = this.$slots.default();
return h('div', {
class: 'novjtcto'
}, [
h('div', label),
...options.map(option => h(MkRadio, {
key: option.props.value,
value: option.props.value,
modelValue: this.value,
'onUpdate:modelValue': value => this.value = value,
}, option.children))
]);
}
});
</script>