RemindBox.vue 961 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <div class="com-remind-box" v-show="showBox">{{title}}</div>
  3. </template>
  4. <script>
  5. export default {
  6. props: ['title', 'timeoutCount'],
  7. data () {
  8. return {
  9. showBox: false,
  10. timer: ''
  11. }
  12. },
  13. watch: {
  14. timeoutCount: function (val, oldVal) {
  15. if (val > 0) {
  16. clearTimeout(this.timer)
  17. this.setTimer()
  18. } else {
  19. this.showBox = false
  20. }
  21. }
  22. },
  23. methods: {
  24. setTimer: function () {
  25. let _this = this
  26. _this.showBox = true
  27. _this.timer = setTimeout(function () {
  28. _this.showBox = false
  29. }, 1000)
  30. }
  31. }
  32. }
  33. </script>
  34. <style>
  35. .com-remind-box{
  36. position: fixed;
  37. top: 50%;
  38. left: 50%;
  39. margin-left: -1.07rem;
  40. margin-top: -.6rem;
  41. z-index: 100;
  42. background: rgba(0,0,0,.6);
  43. color: #fff;
  44. font-size: .28rem;
  45. padding: .44rem .51rem;
  46. border-radius: .1rem;
  47. }
  48. </style>