index.js 1.1 KB

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