index.js 837 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { use } from '../utils';
  2. import { CheckboxMixin } from '../mixins/checkbox';
  3. var _use = use('radio'),
  4. sfc = _use[0],
  5. bem = _use[1];
  6. export default sfc({
  7. mixins: [CheckboxMixin('van-radio-group', bem)],
  8. computed: {
  9. currentValue: {
  10. get: function get() {
  11. return this.parent ? this.parent.value : this.value;
  12. },
  13. set: function set(val) {
  14. (this.parent || this).$emit('input', val);
  15. }
  16. },
  17. checked: function checked() {
  18. return this.currentValue === this.name;
  19. }
  20. },
  21. methods: {
  22. onClickIcon: function onClickIcon() {
  23. if (!this.isDisabled) {
  24. this.currentValue = this.name;
  25. }
  26. },
  27. onClickLabel: function onClickLabel() {
  28. if (!this.isDisabled && !this.labelDisabled) {
  29. this.currentValue = this.name;
  30. }
  31. }
  32. }
  33. });