ModalWrapper.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. }
  31. }
  32. }
  33. },
  34. methods: {
  35. init () {
  36. this.$nextTick(() => {
  37. this._initscroll()
  38. })
  39. }
  40. },
  41. mounted() {
  42. this.init()
  43. }
  44. }
  45. </script>
  46. <style lang="scss" scoped>
  47. .mobile-modal .mobile-modal-wrapper {
  48. top: 1.6rem;
  49. bottom: 1.6rem;
  50. left: 5%;
  51. right: 5%;
  52. }
  53. .mobile-scroll-wrap {
  54. overflow: hidden;
  55. height: 100%;
  56. background: #fff;
  57. }
  58. </style>