index.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <view>
  3. <view class="oa-dropdown" :class="dropdownShow ? 'show' : 'none'">
  4. <view class="content">
  5. <slot name="content"></slot>
  6. </view>
  7. </view>
  8. <view v-if="closeOnClickOverlay" class="oa-dropdown" :class="dropdownShow ? 'mask' : 'none'" @click="close()"> </view>
  9. </view>
  10. </template>
  11. <script setup>
  12. import { onReady, onLoad, onShow, onNavigationBarButtonTap, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
  13. import { ref, onMounted, inject, shallowRef, reactive, getCurrentInstance, watchEffect, toRefs } from "vue";
  14. const emit = defineEmits(["close"]);
  15. const props = defineProps({
  16. //显示隐藏
  17. dropdownShow: {
  18. type: Boolean,
  19. default: false,
  20. },
  21. //是否开启遮罩层关闭
  22. closeOnClickOverlay: {
  23. type: Boolean,
  24. default: true,
  25. },
  26. });
  27. const { dropdownShow, closeOnClickOverlay } = toRefs(props);
  28. function close() {
  29. emit("close", false);
  30. }
  31. </script>
  32. <style lang="scss" scoped>
  33. .oa-dropdown {
  34. position: absolute;
  35. width: 100%;
  36. background-color: #fff;
  37. max-height: 0;
  38. overflow: hidden;
  39. z-index: 90;
  40. transition: max-height 0.4s ease-in-out;
  41. box-shadow: 0px 1px 2px 0px rgba(141, 141, 141, 0.4);
  42. &.show {
  43. max-height: 100%;
  44. }
  45. &.mask {
  46. position: fixed;
  47. top: 0;
  48. left: 0;
  49. right: 0;
  50. bottom: 0;
  51. background-color: transparent;
  52. height: 100%;
  53. z-index: 50;
  54. }
  55. .content {
  56. padding: 10px;
  57. }
  58. }
  59. </style>