block.vue 696 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <template>
  2. <view class="hc-tabbar-block-box" :style="{ 'height': heights }"></view>
  3. </template>
  4. <script setup>
  5. import {onMounted, ref, watch} from "vue";
  6. const props = defineProps({
  7. 'height': {
  8. type: [String, Number],
  9. default: '70'
  10. }
  11. });
  12. //初始变量
  13. const heights = ref('');
  14. //加载完成
  15. onMounted(() => {
  16. setStyleData(props.height);
  17. });
  18. //监听变化
  19. watch(() => [
  20. props.height
  21. ], ([height]) => {
  22. setStyleData(height);
  23. })
  24. //设置样式
  25. const setStyleData = (height) => {
  26. heights.value = (height * 2) + 'rpx';
  27. }
  28. </script>
  29. <style scoped lang="scss">
  30. .hc-tabbar-block-box {
  31. padding-bottom: calc(var(--window-bottom) + 34rpx);
  32. }
  33. </style>