ModalWrapper.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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">{{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. },
  21. watch: {
  22. showModal: {
  23. handler: function (val) {
  24. if (val) {
  25. this.init()
  26. }
  27. }
  28. }
  29. },
  30. methods: {
  31. init () {
  32. this.$nextTick(() => {
  33. this._initscroll()
  34. })
  35. }
  36. },
  37. mounted() {
  38. this.init()
  39. }
  40. }
  41. </script>
  42. <style lang="scss" scoped>
  43. .mobile-modal .mobile-modal-wrapper {
  44. top: 11%;
  45. bottom: 11%;
  46. left: 5%;
  47. right: 5%;
  48. }
  49. .mobile-scroll-wrap {
  50. overflow: hidden;
  51. height: 100%;
  52. background: #fff;
  53. }
  54. </style>