index.js 664 B

123456789101112131415161718192021222324
  1. import { RadioDefaultProps } from './props';
  2. import fmtEvent from '../_util/fmtEvent';
  3. import mixinValue from '../mixins/value';
  4. import '../_util/assert-component2';
  5. Component({
  6. props: RadioDefaultProps,
  7. mixins: [
  8. mixinValue({
  9. valueKey: 'checked',
  10. defaultValueKey: 'defaultChecked',
  11. }),
  12. ],
  13. methods: {
  14. onChange: function (e) {
  15. var value = e.detail.value;
  16. if (!this.isControlled()) {
  17. this.update(value);
  18. }
  19. if (this.props.onChange) {
  20. this.props.onChange(value, fmtEvent(this.props, e));
  21. }
  22. },
  23. },
  24. });