notice.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <div class="flex flex-center flex-justify-start">
  3. <el-icon class="mr-10" color="#A3773D" size="18">
  4. <Bell />
  5. </el-icon>
  6. <div class="roll full-width">
  7. <ul :class="{ marquee_top: animate }">
  8. <li v-for="(item, index) in data" :key="index" class="pointer">
  9. <div class="flex flex-center flex-justify-between">
  10. <preview :id="item.fileId">
  11. <template #title>
  12. <div class="main-color">
  13. {{ item.title }}
  14. </div>
  15. </template>
  16. </preview>
  17. </div>
  18. </li>
  19. </ul>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import preview from '@/views/resource/component/preview.vue'
  25. export default {
  26. components: { preview },
  27. props: {
  28. data: {
  29. type: Array,
  30. default: null
  31. }
  32. },
  33. data() {
  34. return {
  35. animate: false,
  36. setInTime: '' // 定时器
  37. }
  38. },
  39. mounted() {
  40. this.setInTime = setInterval(this.showMarquee, 5000)
  41. },
  42. unmounted() {
  43. clearInterval(this.setInTime) // 页面销毁时清除定时器
  44. },
  45. methods: {
  46. // 滚动栏滚动
  47. showMarquee() {
  48. this.animate = true
  49. setTimeout(() => {
  50. this.data.push(this.data[0])
  51. this.data.shift()
  52. this.animate = false
  53. }, 500)
  54. }
  55. }
  56. }
  57. </script>
  58. <style lang="scss" scoped>
  59. .roll {
  60. height: 20px;
  61. width: 1200px;
  62. text-align: left;
  63. overflow: hidden;
  64. }
  65. .marquee_top {
  66. transition: all 0.5s;
  67. margin-top: -20px; /* 容器高度 */
  68. }
  69. </style>