index.js 722 B

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