index.js 783 B

12345678910111213141516171819202122232425262728
  1. import { TabBarDefaultProps } from './props';
  2. import fmtEvent from '../_util/fmtEvent';
  3. import mixinValue from '../mixins/value';
  4. import '../_util/assert-component2';
  5. Component({
  6. props: TabBarDefaultProps,
  7. mixins: [
  8. mixinValue({
  9. valueKey: 'current',
  10. defaultValueKey: 'defaultCurrent',
  11. }),
  12. ],
  13. methods: {
  14. onChange: function (e) {
  15. var index = e.target.dataset.index;
  16. var onChange = this.props.onChange;
  17. if (index === this.getValue()) {
  18. return;
  19. }
  20. if (!this.isControlled()) {
  21. this.update(index);
  22. }
  23. if (onChange) {
  24. onChange(index, fmtEvent(this.props, e));
  25. }
  26. },
  27. },
  28. });