<template>
  <div class="mobile-modal" v-if="showModal" @click="$emit('closeAction')">
    <div class="mobile-modal-box mobile-modal-wrapper" @click="stopPropagation($event)">
      <div class="mobile-modal-header">{{title}}<i @click="$emit('closeAction')" class="icon-guanbi iconfont"></i></div>
      <div ref="mobileModalBox" class="mobile-scroll-wrap"><div><slot></slot></div></div>
    </div>
  </div>
</template>
<script>
  export default {
    props: {
      showModal: {
        type: Boolean,
        default: false
      },
      title: {
        type: String,
        default: ''
      }
    },
    watch: {
      showModal: {
        handler: function (val) {
          if (val) {
            this.init()
          }
        }
      }
    },
    methods: {
      init () {
        this.$nextTick(() => {
          this._initscroll()
        })
      }
    },
    mounted() {
      this.init()
    }
  }
</script>
<style lang="scss" scoped>
  .mobile-modal .mobile-modal-wrapper {
    top: 11%;
    bottom: 11%;
    left: 5%;
    right: 5%;
  }
  .mobile-scroll-wrap {
    overflow: hidden;
    height: 100%;
    background: #fff;
  }
</style>
