index.vue 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <uni-shadow-root class="vant-dist-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/dist/tab/index'
  9. import { useParent } from '../common/relation';
  10. import { VantComponent } from '../common/component';
  11. VantComponent({
  12. relation: useParent('tabs'),
  13. props: {
  14. dot: {
  15. type: Boolean,
  16. observer: 'update',
  17. },
  18. info: {
  19. type: null,
  20. observer: 'update',
  21. },
  22. title: {
  23. type: String,
  24. observer: 'update',
  25. },
  26. disabled: {
  27. type: Boolean,
  28. observer: 'update',
  29. },
  30. titleStyle: {
  31. type: String,
  32. observer: 'update',
  33. },
  34. name: {
  35. type: null,
  36. value: '',
  37. },
  38. },
  39. data: {
  40. active: false,
  41. },
  42. methods: {
  43. getComputedName() {
  44. if (this.data.name !== '') {
  45. return this.data.name;
  46. }
  47. return this.index;
  48. },
  49. updateRender(active, parent) {
  50. const { data: parentData } = parent;
  51. this.inited = this.inited || active;
  52. this.setData({
  53. active,
  54. shouldRender: this.inited || !parentData.lazyRender,
  55. shouldShow: active || parentData.animated,
  56. });
  57. },
  58. update() {
  59. if (this.parent) {
  60. this.parent.updateTabs();
  61. }
  62. },
  63. },
  64. });
  65. export default global['__wxComponents']['vant/dist/tab/index']
  66. </script>
  67. <style platform="mp-weixin">
  68. @import '../common/index.css';.vant-dist-tab-index{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}
  69. </style>