
<template>
  <transition name="fade">
    <div
      class="ac-toast"
      v-show="visible">
      {{ message }}
    </div>
  </transition>
</template>

<script>
  import layerMixin from '../../layer/layerMixin.js'
  export default {
    name: 'AcToast',
    mixins: [layerMixin],
    mounted () {
      // 设定的时间后自动关闭
      setTimeout(() => {
        this.close()
      }, this.duration)
    },
    props: {
      message: {
        type: String,
        default: '你有一条消息'
      },
      duration: {
        type: Number,
        default: 3000
      }
    }
  }
</script>

<style type="text/css">
  .ac-toast {
    position: fixed;
    padding: 10px;
    color: #fff;
    background-color: #5F6161;
    border-radius: 4px;
    top:50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000
  }
  .fade-enter-active, .fade-leave-active {
    transition: opacity .5s
  }
  .fade-enter, .fade-leave-to /* .fade-leave-active in below version 2.1.8 */ {
    opacity: 0
  }
</style>
