index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { VantComponent } from '../common/component';
  2. VantComponent({
  3. relation: {
  4. name: 'tabs',
  5. type: 'ancestor',
  6. linked(target) {
  7. this.parent = target;
  8. },
  9. unlinked() {
  10. this.parent = null;
  11. }
  12. },
  13. props: {
  14. dot: Boolean,
  15. info: null,
  16. title: String,
  17. disabled: Boolean,
  18. titleStyle: String,
  19. name: {
  20. type: [Number, String],
  21. value: '',
  22. }
  23. },
  24. data: {
  25. active: false
  26. },
  27. watch: {
  28. title: 'update',
  29. disabled: 'update',
  30. dot: 'update',
  31. info: 'update',
  32. titleStyle: 'update'
  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. });