ModalWrapper.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <div class="mobile-modal" v-if="showModal" @click="$emit('closeAction')">
  3. <div class="mobile-modal-box mobile-modal-wrapper" @click="stopPropagation($event)">
  4. <div class="mobile-modal-header" v-if="!noHeader">{{title}}<i @click="$emit('closeAction')" class="icon-guanbi iconfont"></i></div>
  5. <div ref="mobileModalBox" class="mobile-scroll-wrap"><div><slot></slot></div></div>
  6. </div>
  7. </div>
  8. </template>
  9. <script>
  10. export default {
  11. props: {
  12. showModal: {
  13. type: Boolean,
  14. default: false
  15. },
  16. title: {
  17. type: String,
  18. default: ''
  19. },
  20. noHeader: {
  21. type: Boolean,
  22. default: false
  23. }
  24. },
  25. watch: {
  26. showModal: {
  27. handler: function (val) {
  28. if (val) {
  29. this.init()
  30. } else {
  31. this.initScroll.destroy()
  32. this.initScroll = null
  33. }
  34. }
  35. }
  36. },
  37. methods: {
  38. init () {
  39. this.$nextTick(() => {
  40. this._initscroll()
  41. })
  42. }
  43. },
  44. mounted() {
  45. this.init()
  46. }
  47. }
  48. </script>
  49. <style lang="scss" scoped>
  50. .mobile-modal .mobile-modal-wrapper {
  51. top: 1.6rem;
  52. bottom: 1.6rem;
  53. left: 5%;
  54. right: 5%;
  55. }
  56. .mobile-scroll-wrap {
  57. overflow: hidden;
  58. height: 100%;
  59. background: #fff;
  60. border-bottom-left-radius: .07rem;
  61. border-bottom-right-radius: .07rem;
  62. }
  63. </style>