海鲜小程序

index.js 1.1KB

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