index.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. console.log(event);
  38. this.emitChange(this.data.name);
  39. },
  40. onClickLabel() {
  41. const { disabled, labelDisabled, name } = this.data;
  42. if (!disabled && !labelDisabled) {
  43. this.emitChange(name);
  44. }
  45. }
  46. }
  47. });