dialog.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <view v-if="visible" class="dialog" @click="handleClose">
  3. <view
  4. class="dialog-container"
  5. :style="styleConfig"
  6. >
  7. <slot />
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. import { defineComponent, watchEffect, watch, reactive, toRefs } from 'vue';
  13. export default defineComponent({
  14. name: 'dialog',
  15. props: {
  16. visible: {
  17. type: Boolean,
  18. default: () => {
  19. return false;
  20. }
  21. },
  22. styleConfig: {
  23. type: Object,
  24. default: () => {
  25. return {
  26. width: '240px',
  27. // height: '120px',
  28. padding: '16px',
  29. top: '10px',
  30. right: '10px',
  31. };
  32. }
  33. },
  34. handleClose: {
  35. type: Function,
  36. default: () => {}
  37. }
  38. },
  39. setup(props, context) {
  40. },
  41. });
  42. </script>
  43. <style lang="scss" scoped>
  44. .dialog {
  45. position: fixed;
  46. width: 100%;
  47. height: 100%;
  48. z-index: 9999;
  49. top: 0px;
  50. left: 0;
  51. background-color: rgba(255, 255, 255, 0.1);
  52. top: 0;
  53. right: 0;
  54. display: flex;
  55. justify-content: center;
  56. align-items: center;
  57. &-container {
  58. position: absolute;
  59. width: 120px;
  60. border-radius: 10px;
  61. box-shadow: 0 0 10px 0 rgba(0,0,0,0.21);
  62. background-color: rgba(255, 255, 255, 1);
  63. }
  64. }
  65. </style>