ScrollNotice.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <view class="notice-main">
  3. <view class="notice-icon">
  4. <image src="/static/index/u01.png" mode=""></image>
  5. </view>
  6. <view class="notice-swiper-wrap">
  7. <swiper class="notice-swiper" :style="'height:'+height+'px;line-height:'+height+'px;'" autoplay="true"
  8. :interval="interval" duration="500" circular="true" :vertical="type==1?true:false">
  9. <swiper-item v-for="(list,index) in dataList" :key="index" @click.stop="clickList(list)">
  10. <view class="notice-swiper-item" :style="'font-size:'+fontSize+'px;color:'+color">
  11. {{list.noticeTitle}}
  12. </view>
  13. </swiper-item>
  14. </swiper>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. props: {
  21. //通知列表
  22. dataList: {
  23. type: Array,
  24. default: () => {
  25. return []
  26. }
  27. },
  28. //滚动类型(1:向上循环滚动;2:横向滚动)
  29. type: {
  30. type: Number,
  31. default: 1
  32. },
  33. //滚动时间间隔
  34. interval: {
  35. type: Number,
  36. default: 1000
  37. },
  38. //通告栏高度(rpx)
  39. height: {
  40. type: Number,
  41. default: 66
  42. },
  43. //字体大小(rpx)
  44. fontSize: {
  45. type: Number,
  46. default: 30
  47. },
  48. //字体颜色
  49. color: {
  50. type: String,
  51. default: '#333333'
  52. },
  53. //自定义取值名字
  54. customName: {
  55. type: String,
  56. default: 'title'
  57. },
  58. },
  59. data() {
  60. return {
  61. };
  62. },
  63. methods: {
  64. clickList(item) {
  65. this.$emit("click", item)
  66. }
  67. }
  68. }
  69. </script>
  70. <style scoped>
  71. .notice-main {
  72. z-index: 100;
  73. width: 100%;
  74. display: flex;
  75. align-items: center;
  76. }
  77. .notice-icon{
  78. width: 8%;
  79. }
  80. .notice-icon image{
  81. height: 16px;
  82. width: 16px;
  83. }
  84. .notice-swiper-wrap{
  85. width: 90%;
  86. }
  87. .notice-swiper-item {
  88. overflow: hidden;
  89. text-overflow: ellipsis;
  90. display: -webkit-box;
  91. -webkit-box-orient: vertical;
  92. -webkit-line-clamp: 1;
  93. }
  94. </style>