index.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <uni-shadow-root class="vant-tab-index"><view :class="'custom-class '+(utils.bem('tab__pane', { active, inactive: !active }))" :style="shouldShow ? '' : 'display: none;'">
  3. <slot v-if="shouldRender"></slot>
  4. </view></uni-shadow-root>
  5. </template>
  6. <wxs src="../wxs/utils.wxs" module="utils"></wxs>
  7. <script>
  8. global['__wxRoute'] = 'vant/tab/index'
  9. import { VantComponent } from '../common/component';
  10. VantComponent({
  11. relation: {
  12. name: 'tabs',
  13. type: 'ancestor',
  14. current: 'tab',
  15. },
  16. props: {
  17. dot: {
  18. type: Boolean,
  19. observer: 'update',
  20. },
  21. info: {
  22. type: null,
  23. observer: 'update',
  24. },
  25. title: {
  26. type: String,
  27. observer: 'update',
  28. },
  29. disabled: {
  30. type: Boolean,
  31. observer: 'update',
  32. },
  33. titleStyle: {
  34. type: String,
  35. observer: 'update',
  36. },
  37. name: {
  38. type: [Number, String],
  39. value: '',
  40. },
  41. },
  42. data: {
  43. active: false,
  44. },
  45. methods: {
  46. getComputedName() {
  47. if (this.data.name !== '') {
  48. return this.data.name;
  49. }
  50. return this.index;
  51. },
  52. updateRender(active, parent) {
  53. const { data: parentData } = parent;
  54. this.inited = this.inited || active;
  55. this.setData({
  56. active,
  57. shouldRender: this.inited || !parentData.lazyRender,
  58. shouldShow: active || parentData.animated,
  59. });
  60. },
  61. update() {
  62. if (this.parent) {
  63. this.parent.updateTabs();
  64. }
  65. },
  66. },
  67. });
  68. export default global['__wxComponents']['vant/tab/index']
  69. </script>
  70. <style platform="mp-weixin">
  71. @import '../common/index.css';.vant-tab-index{-webkit-flex-shrink:0;flex-shrink:0;width:100%}.van-tab__pane,:host{box-sizing:border-box}.van-tab__pane{overflow-y:auto;-webkit-overflow-scrolling:touch}.van-tab__pane--active{height:auto}.van-tab__pane--inactive{height:0;overflow:visible}
  72. </style>