BaseRadio.vue 978 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <div class="form-check-radio">
  3. <label :for="cbId" class="form-check-label">
  4. <input :id="cbId"
  5. type="radio"
  6. :disabled="disabled"
  7. :value="label"
  8. v-model="model" />
  9. <span class="form-check-sign">
  10. <slot></slot>
  11. </span>
  12. </label>
  13. </div>
  14. </template>
  15. <script>
  16. export default {
  17. name: 'base-radio',
  18. props: {
  19. label: [String, Number],
  20. disabled: [Boolean, String],
  21. value: [String, Boolean],
  22. inline: Boolean
  23. },
  24. data () {
  25. return {
  26. cbId: ''
  27. }
  28. },
  29. computed: {
  30. model: {
  31. get () {
  32. return this.value
  33. },
  34. set (value) {
  35. this.$emit('input', value)
  36. }
  37. },
  38. inlineClass () {
  39. if (this.inline) {
  40. return `radio-inline`
  41. }
  42. return ''
  43. }
  44. },
  45. created () {
  46. this.cbId = Math.random().toString(16).slice(2)
  47. }
  48. }
  49. </script>