项目原始demo,不改动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 

82 lines
1.9 KiB

  1. // Mixins
  2. import { factory as GroupableFactory } from '../../mixins/groupable';
  3. import Routable from '../../mixins/routable';
  4. import Themeable from '../../mixins/themeable'; // Utilities
  5. import { keyCodes } from './../../util/helpers';
  6. import mixins from '../../util/mixins';
  7. const baseMixins = mixins(Routable, // Must be after routable
  8. // to overwrite activeClass
  9. GroupableFactory('tabsBar'), Themeable);
  10. export default baseMixins.extend().extend().extend({
  11. name: 'v-tab',
  12. props: {
  13. ripple: {
  14. type: [Boolean, Object],
  15. default: true
  16. }
  17. },
  18. data: () => ({
  19. proxyClass: 'v-tab--active'
  20. }),
  21. computed: {
  22. classes() {
  23. return {
  24. 'v-tab': true,
  25. ...Routable.options.computed.classes.call(this),
  26. 'v-tab--disabled': this.disabled,
  27. ...this.groupClasses
  28. };
  29. },
  30. value() {
  31. let to = this.to || this.href || '';
  32. if (this.$router && this.to === Object(this.to)) {
  33. const resolve = this.$router.resolve(this.to, this.$route, this.append);
  34. to = resolve.href;
  35. }
  36. return to.replace('#', '');
  37. }
  38. },
  39. mounted() {
  40. this.onRouteChange();
  41. },
  42. methods: {
  43. click(e) {
  44. // If user provides an
  45. // actual link, do not
  46. // prevent default
  47. if (this.href && this.href.indexOf('#') > -1) e.preventDefault();
  48. if (e.detail) this.$el.blur();
  49. this.$emit('click', e);
  50. this.to || this.toggle();
  51. }
  52. },
  53. render(h) {
  54. const {
  55. tag,
  56. data
  57. } = this.generateRouteLink();
  58. data.attrs = { ...data.attrs,
  59. 'aria-selected': String(this.isActive),
  60. role: 'tab',
  61. tabindex: 0
  62. };
  63. data.on = { ...data.on,
  64. keydown: e => {
  65. if (e.keyCode === keyCodes.enter) this.click(e);
  66. this.$emit('keydown', e);
  67. }
  68. };
  69. return h(tag, data, this.$slots.default);
  70. }
  71. });
  72. //# sourceMappingURL=VTab.js.map