index.js 1001 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { VantComponent } from '../common/component';
  2. import { useParent } from '../common/relation';
  3. VantComponent({
  4. field: true,
  5. relation: useParent('radio-group'),
  6. classes: ['icon-class', 'label-class'],
  7. props: {
  8. name: null,
  9. value: null,
  10. disabled: Boolean,
  11. useIconSlot: Boolean,
  12. checkedColor: String,
  13. labelPosition: {
  14. type: String,
  15. value: 'right',
  16. },
  17. labelDisabled: Boolean,
  18. shape: {
  19. type: String,
  20. value: 'round',
  21. },
  22. iconSize: {
  23. type: null,
  24. value: 20,
  25. },
  26. },
  27. methods: {
  28. emitChange(value) {
  29. const instance = this.parent || this;
  30. instance.$emit('input', value);
  31. instance.$emit('change', value);
  32. },
  33. onChange() {
  34. if (!this.data.disabled) {
  35. this.emitChange(this.data.name);
  36. }
  37. },
  38. onClickLabel() {
  39. const { disabled, labelDisabled, name } = this.data;
  40. if (!disabled && !labelDisabled) {
  41. this.emitChange(name);
  42. }
  43. },
  44. },
  45. });