client: refactor radio.vue to composition api

This commit is contained in:
Norm 2022-09-08 02:02:29 -04:00 committed by Gitea
parent 8d5966c0bc
commit d9f443c6c1

View file

@ -18,34 +18,25 @@
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
export default defineComponent({
props: {
modelValue: {
required: false,
},
value: {
required: false,
},
disabled: {
type: Boolean,
default: false,
},
},
computed: {
checked(): boolean {
return this.modelValue === this.value;
},
},
methods: {
toggle() {
if (this.disabled) return;
this.$emit('update:modelValue', this.value);
},
},
<script lang="ts" setup>
type ValueType = string | number | symbol;
const props = withDefaults(defineProps<{
modelValue?: ValueType;
value?: ValueType;
disabled?: boolean;
}>(), {
disabled: false,
});
const emit = defineEmits<{
(ev: 'update:modelValue', value?: ValueType): void;
}>();
const checked = $computed(() => props.modelValue === props.value);
function toggle(): void {
if (props.disabled) return;
emit('update:modelValue', props.value);
}
</script>
<style lang="scss" scoped>