FullScreen.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <div
  3. v-show="dialogStatus"
  4. :style="{'background-color': `rgba(0, 0, 0, ${alpha})`, 'z-index': zIndex}"
  5. class="full-screen-dialog-wrap"
  6. @click="$emit('close')">
  7. <div
  8. :style="{ width: width }"
  9. class="full-screen-dialog-container"
  10. @click.stop>
  11. <slot/>
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. export default {
  17. name: 'FullScreen',
  18. props: {
  19. dialogStatus: {
  20. type: Boolean,
  21. default: false
  22. },
  23. alpha: {
  24. type: Number,
  25. default: 0.85
  26. },
  27. zIndex: {
  28. type: Number,
  29. default: 1000
  30. },
  31. width: {
  32. type: String,
  33. default: '500px'
  34. }
  35. },
  36. watch: {
  37. dialogStatus(status) {
  38. document.body.style.overflow = status ? 'hidden' : ''
  39. }
  40. },
  41. mounted() {
  42. // 固定body样式
  43. document.body.style.overflow = this.dialogStatus ? 'hidden' : ''
  44. },
  45. destroyed() {
  46. // 取消固定body样式
  47. document.body.style.overflow = ''
  48. }
  49. }
  50. </script>
  51. <style lang="less">
  52. .full-screen-dialog-wrap {
  53. position: fixed;
  54. top: 0;
  55. left: 0;
  56. right: 0;
  57. bottom: 0;
  58. overflow: auto;
  59. display: flex;
  60. padding: 50px;
  61. .full-screen-dialog-container {
  62. position: relative;
  63. margin: auto;
  64. }
  65. }
  66. </style>