rgbwifi/web/src/components/radio.vue

41 lines
717 B
Vue

<template>
<div class="radio" :class="{ checked: value == id, disabled: disabled }" @keydown="handleKeyDown" @click="handleClick" tabindex="0">
<div class="control">
<div class="inner"></div>
</div>
<div class="label">{{ title }}</div>
</div>
</template>
<script>
export default {
props: {
title: String,
value: null,
id: null,
disabled: {
type: Boolean,
default: false
}
},
methods: {
handleClick()
{
if (this.disabled)
return;
this.$emit('input', this.id);
},
handleKeyDown(event)
{
if (event.keyCode == 32)
{
this.handleClick();
event.preventDefault();
}
}
}
}
</script>