index.js 575 B

1234567891011121314151617181920
  1. import { TabBarDefaultProps } from './props';
  2. import { Component, triggerEvent } from '../_util/simply';
  3. import mixinValue from '../mixins/value';
  4. Component(TabBarDefaultProps, {
  5. onChange: function (e) {
  6. var index = e.currentTarget.dataset.index;
  7. if (index === this.getValue()) {
  8. return;
  9. }
  10. if (!this.isControlled()) {
  11. this.update(index);
  12. }
  13. triggerEvent(this, 'change', index, e);
  14. },
  15. }, null, [
  16. mixinValue({
  17. valueKey: 'current',
  18. defaultValueKey: 'defaultCurrent',
  19. }),
  20. ]);