index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <!--
  2. 描述: 新闻无缝滚动
  3. 作者: Jack Chen
  4. 日期: 2020-04-18
  5. -->
  6. <template>
  7. <div class="wrap-container sn-container">
  8. <div class="sn-content">
  9. <div class="sn-title">新闻无缝滚动</div>
  10. <div class="sn-body">
  11. <div class="wrap-container">
  12. <div class="table">
  13. <table border="0" cellpadding="0" cellspacing="0" class="table-header">
  14. <tbody>
  15. <tr>
  16. <td width="60%">
  17. <span>标 题</span>
  18. </td>
  19. <td width="20%">
  20. <span>日 期</span>
  21. </td>
  22. <td width="20%">
  23. <span>热 度</span>
  24. </td>
  25. </tr>
  26. </tbody>
  27. </table>
  28. <vue-seamless-scroll :data="listData" class="seamless-warp" :class-option="optionSetting">
  29. <table border="0" cellpadding="0" cellspacing="0" class="item">
  30. <tbody>
  31. <tr v-for="(item, index) in listData" :key="index">
  32. <td width="100%" class="title">
  33. <span :class="{colorRed: item.hot > 4999}">{{ item.title }}</span>
  34. </td>
  35. <td width="20%">
  36. <span>{{ item.date }}</span>
  37. </td>
  38. <td width="20%">
  39. <span :class="{colorRed: item.hot > 4999, colorOrange: item.hot < 10}">{{ item.hot }}</span>
  40. </td>
  41. </tr>
  42. </tbody>
  43. </table>
  44. </vue-seamless-scroll>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. import vueSeamlessScroll from 'vue-seamless-scroll'
  53. export default {
  54. name: "seamless",
  55. components: {
  56. vueSeamlessScroll
  57. },
  58. data() {
  59. return {
  60. listData: [{
  61. title: '钱花哪了?一图带你读懂年轻人的消费观',
  62. date: '2020-05-05',
  63. hot: 2306
  64. }, {
  65. title: '“五一”假期前三天国内旅游收入超350亿元',
  66. date: '2020-05-02',
  67. hot: 5689
  68. }, {
  69. title: '滴滴、美团、哈啰多赛道交战,本地生活会是终局?',
  70. date: '2020-05-02',
  71. hot: 9
  72. }, {
  73. title: '“互联网+文化”逆势上行文娱消费,云端真精彩',
  74. date: '2020-04-25',
  75. hot: 288
  76. }, {
  77. title: '乐观主义还是悲观主义?巴菲特事实上是个现实主义者!',
  78. date: '2020-04-21',
  79. hot: 158
  80. }, {
  81. title: 'B站的后浪,会把爱优腾拍在沙滩上吗?',
  82. date: '2020-04-20',
  83. hot: 889
  84. }, {
  85. title: '华为是如何做投资的:先给两个亿订单 一年送上市',
  86. date: '2020-04-01',
  87. hot: 5800
  88. }, {
  89. title: '马斯克:特斯拉股价太高了,我要卖豪宅',
  90. date: '2020-03-25',
  91. hot: 6
  92. }, {
  93. title: '人民日报海外版:云模式巧解“就业难”',
  94. date: '2020-03-16',
  95. hot: 88
  96. }, {
  97. title: '刚刚港股"崩了":狂跌近1000点!发生什么?',
  98. date: '2020-03-12',
  99. hot: 88
  100. }, {
  101. title: '个人健康信息码国家标准发布',
  102. date: '2020-02-28',
  103. hot: 5
  104. }, {
  105. title: '传软银国际裁员约10% 拉美基金两名管理合伙人离职',
  106. date: '2020-02-15',
  107. hot: 258
  108. }, {
  109. title: '27.5万个岗位:事业单位、人工智能等热门专场招聘',
  110. date: '2020-02-10',
  111. hot: 198
  112. }, {
  113. title: '一季度电子商务发展势头迅猛 农村电商突破1300万家',
  114. date: '2020-02-08',
  115. hot: 19
  116. }]
  117. }
  118. },
  119. computed: {
  120.   optionSetting () {
  121. return {
  122. step: 0.5, // 数值越大速度滚动越快
  123. limitMoveNum: 2, // 开始无缝滚动的数据量 this.dataList.length
  124. hoverStop: true, // 是否开启鼠标悬停stop
  125. direction: 1, // 0向下 1向上 2向左 3向右
  126. // autoPlay: false,
  127. openWatch: true, // 开启数据实时监控刷新dom
  128. singleHeight: 0, // 单步运动停止的高度(默认值0是无缝不停止的滚动) direction => 0/1
  129. singleWidth: 0, // 单步运动停止的宽度(默认值0是无缝不停止的滚动) direction => 2/3
  130. waitTime: 1000 // 单步运动停止的时间(默认值1000ms)
  131. }
  132. }
  133. },
  134. mounted() {
  135. },
  136. methods: {
  137. },
  138. beforeDestroy() {
  139. }
  140. };
  141. </script>
  142. <style lang="scss" scoped>
  143. .sn-container {
  144. left: 1370px;
  145. top: 110px;
  146. %table-style {
  147. width: 100%;
  148. height: 35px;
  149. table-layout: fixed;
  150. tr {
  151. td {
  152. padding: 10px 5px;
  153. text-align: center;
  154. background-color: transparent;
  155. white-space: nowrap;
  156. overflow: hidden;
  157. color: #E2E5FF;
  158. font-size: 14px;
  159. }
  160. }
  161. }
  162. .table {
  163. .table-header {
  164. @extend %table-style;
  165. }
  166. .seamless-warp {
  167. height: 400px;
  168. overflow: hidden;
  169. visibility: visible;
  170. .colorRed {
  171. color: #FF4669;
  172. }
  173. .colorOrange {
  174. color: #FFC956;
  175. }
  176. .item {
  177. height: auto;
  178. @extend %table-style;
  179. tr {
  180. td {
  181. &.title {
  182. text-overflow: ellipsis;
  183. display: inline-block;
  184. }
  185. }
  186. }
  187. }
  188. }
  189. }
  190. }
  191. </style>