|
|
@@ -1,12 +1,26 @@
|
|
|
<template>
|
|
|
- <view class="nut-tabbar" :class="{ 'nut-tabbar-bottom': bottom, 'nut-tabbar-safebottom': safeAreaInsetBottom }">
|
|
|
+ <div v-if="bottom && placeholder" class="nut-tabbar__placeholder" :style="{ height: height + 'px' }">
|
|
|
+ <view
|
|
|
+ ref="nutTabbar"
|
|
|
+ class="nut-tabbar"
|
|
|
+ :class="{ 'nut-tabbar-bottom': bottom, 'nut-tabbar-safebottom': safeAreaInsetBottom }"
|
|
|
+ >
|
|
|
+ <slot></slot>
|
|
|
+ </view>
|
|
|
+ </div>
|
|
|
+ <view
|
|
|
+ v-else
|
|
|
+ class="nut-tabbar"
|
|
|
+ :class="{ 'nut-tabbar-bottom': bottom, 'nut-tabbar-safebottom': safeAreaInsetBottom }"
|
|
|
+ >
|
|
|
<slot></slot>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts">
|
|
|
-import { provide, reactive, watch } from 'vue';
|
|
|
+import { onMounted, provide, reactive, ref, toRefs, watch } from 'vue';
|
|
|
import { createComponent } from '@/packages/utils/create';
|
|
|
+import Taro from '@tarojs/taro';
|
|
|
const { create } = createComponent('tabbar');
|
|
|
export default create({
|
|
|
props: {
|
|
|
@@ -37,14 +51,20 @@ export default create({
|
|
|
safeAreaInsetBottom: {
|
|
|
type: Boolean,
|
|
|
default: false
|
|
|
+ },
|
|
|
+ placeholder: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
}
|
|
|
},
|
|
|
emits: ['tab-switch', 'update:visible'],
|
|
|
setup(props, { emit, slots }) {
|
|
|
+ const { bottom, placeholder } = toRefs(props);
|
|
|
const mdValue = reactive({
|
|
|
val: props.visible,
|
|
|
children: []
|
|
|
});
|
|
|
+ const height = ref();
|
|
|
function changeIndex(index: number, active: number | string) {
|
|
|
emit('update:visible', active);
|
|
|
parentData.modelValue = active;
|
|
|
@@ -65,8 +85,20 @@ export default create({
|
|
|
parentData.modelValue = value;
|
|
|
}
|
|
|
);
|
|
|
+ onMounted(() => {
|
|
|
+ if (bottom.value && placeholder.value) {
|
|
|
+ setTimeout(() => {
|
|
|
+ const query = Taro.createSelectorQuery();
|
|
|
+ query.select('.nut-tabbar').boundingClientRect();
|
|
|
+ query.exec((res) => {
|
|
|
+ height.value = res[0].height;
|
|
|
+ });
|
|
|
+ }, 500);
|
|
|
+ }
|
|
|
+ });
|
|
|
return {
|
|
|
- changeIndex
|
|
|
+ changeIndex,
|
|
|
+ height
|
|
|
};
|
|
|
}
|
|
|
});
|