index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <uni-shadow-root class="vant-tabbar-index"><view :class="'custom-class '+(border ? 'van-hairline--top-bottom' : '')+' '+(utils.bem('tabbar', { fixed, safe: safeAreaInsetBottom }))" :style="zIndex ? 'z-index: ' + zIndex : ''">
  3. <slot></slot>
  4. </view></uni-shadow-root>
  5. </template>
  6. <wxs src="../wxs/utils.wxs" module="utils"></wxs>
  7. <script>
  8. global['__wxRoute'] = 'vant/tabbar/index'
  9. import { VantComponent } from '../common/component';
  10. VantComponent({
  11. relation: {
  12. name: 'tabbar-item',
  13. type: 'descendant',
  14. current: 'tabbar',
  15. linked(target) {
  16. target.parent = this;
  17. target.updateFromParent();
  18. },
  19. unlinked() {
  20. this.updateChildren();
  21. },
  22. },
  23. props: {
  24. active: {
  25. type: null,
  26. observer: 'updateChildren',
  27. },
  28. activeColor: {
  29. type: String,
  30. observer: 'updateChildren',
  31. },
  32. inactiveColor: {
  33. type: String,
  34. observer: 'updateChildren',
  35. },
  36. fixed: {
  37. type: Boolean,
  38. value: true,
  39. },
  40. border: {
  41. type: Boolean,
  42. value: true,
  43. },
  44. zIndex: {
  45. type: Number,
  46. value: 1,
  47. },
  48. safeAreaInsetBottom: {
  49. type: Boolean,
  50. value: true,
  51. },
  52. },
  53. methods: {
  54. updateChildren() {
  55. const { children } = this;
  56. if (!Array.isArray(children) || !children.length) {
  57. return Promise.resolve();
  58. }
  59. return Promise.all(children.map((child) => child.updateFromParent()));
  60. },
  61. onChange(child) {
  62. const index = this.children.indexOf(child);
  63. const active = child.data.name || index;
  64. if (active !== this.data.active) {
  65. this.$emit('change', active);
  66. }
  67. },
  68. },
  69. });
  70. export default global['__wxComponents']['vant/tabbar/index']
  71. </script>
  72. <style platform="mp-weixin">
  73. @import '../common/index.css';.van-tabbar{display:-webkit-flex;display:flex;box-sizing:initial;width:100%;height:50px;height:var(--tabbar-height,50px);background-color:#fff;background-color:var(--tabbar-background-color,#fff)}.van-tabbar--fixed{position:fixed;bottom:0;left:0}.van-tabbar--safe{padding-bottom:env(safe-area-inset-bottom)}
  74. </style>