index.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. linked(target) {
  15. this.parent = target;
  16. },
  17. unlinked() {
  18. this.parent = null;
  19. }
  20. },
  21. props: {
  22. dot: Boolean,
  23. info: null,
  24. title: String,
  25. disabled: Boolean,
  26. titleStyle: String,
  27. name: {
  28. type: [Number, String],
  29. value: '',
  30. }
  31. },
  32. data: {
  33. active: false
  34. },
  35. watch: {
  36. title: 'update',
  37. disabled: 'update',
  38. dot: 'update',
  39. info: 'update',
  40. titleStyle: 'update'
  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/tab/index']
  66. </script>
  67. <style platform="mp-weixin">
  68. @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}.van-tab__pane--active{height:auto}.van-tab__pane--inactive{height:0;overflow:visible}
  69. </style>