index.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { useParent } from '../common/relation';
  2. import { VantComponent } from '../common/component';
  3. VantComponent({
  4. relation: useParent('tabs'),
  5. props: {
  6. dot: {
  7. type: Boolean,
  8. observer: 'update',
  9. },
  10. info: {
  11. type: null,
  12. observer: 'update',
  13. },
  14. title: {
  15. type: String,
  16. observer: 'update',
  17. },
  18. disabled: {
  19. type: Boolean,
  20. observer: 'update',
  21. },
  22. titleStyle: {
  23. type: String,
  24. observer: 'update',
  25. },
  26. name: {
  27. type: null,
  28. value: '',
  29. },
  30. },
  31. data: {
  32. active: false,
  33. },
  34. methods: {
  35. getComputedName() {
  36. if (this.data.name !== '') {
  37. return this.data.name;
  38. }
  39. return this.index;
  40. },
  41. updateRender(active, parent) {
  42. const { data: parentData } = parent;
  43. this.inited = this.inited || active;
  44. this.setData({
  45. active,
  46. shouldRender: this.inited || !parentData.lazyRender,
  47. shouldShow: active || parentData.animated,
  48. });
  49. },
  50. update() {
  51. if (this.parent) {
  52. this.parent.updateTabs();
  53. }
  54. },
  55. },
  56. });