BasicModal.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <template>
  2. <uni-popup v-bind="$attrs" ref="popup" @change="handleChange" :is-mask-click="isMack" :safe-area='false'>
  3. <slot></slot>
  4. </uni-popup>
  5. </template>
  6. <script setup>
  7. import { ref, computed, unref, watch, nextTick } from 'vue';
  8. const props = defineProps({
  9. open: { type: Boolean, default: false },
  10. isMack: { type: Boolean, default: true }
  11. })
  12. const emit = defineEmits(['update:open'])
  13. const popup = ref()
  14. const getOpen = computed({
  15. get: () => props.open,
  16. set: val => emit('update:open', val)
  17. })
  18. watch(getOpen, (v) => {
  19. nextTick(() => {
  20. const p = unref(popup);
  21. if (!p) return;
  22. v ? p.open() : p.close();
  23. });
  24. }, { flush: 'post', immediate: true })
  25. function handleChange({ show }){
  26. getOpen.value = show
  27. }
  28. </script>
  29. <style scoped lang="scss">
  30. /* 高于 TabBar(z-index:99),弹窗盖住底部导航 */
  31. :deep(.uni-popup) {
  32. z-index: 99999 !important;
  33. top: 0 !important;
  34. left: 0 !important;
  35. right: 0 !important;
  36. bottom: 0 !important;
  37. }
  38. :deep(.uni-popup__wrapper) {
  39. z-index: 99999 !important;
  40. }
  41. </style>