concept.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <div class="concept">
  3. <div class="conceptList" ref="conceptList" :style="{marginTop:conceptMarginTop+'px'}" @mouseover="mousemove" @mouseleave="mouseout">
  4. <div class="item">
  5. <div class="data" v-for="d in data" :title="d.title">◆ {{d.title}}</div>
  6. </div>
  7. <div class="item">
  8. <div class="data" v-for="d in data" :title="d.title">◆ {{d.title}}</div>
  9. </div>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. import { rcpolicy } from '@/request/api.js'
  15. export default {
  16. data() {
  17. return {
  18. data: [],
  19. conceptMarginTop: 0,
  20. boxHeight: '',
  21. timeOut: '',
  22. }
  23. },
  24. mounted() {
  25. this.init()
  26. },
  27. methods: {
  28. //初始化
  29. init() {
  30. // 初始化获取栏目高度
  31. this.getPolicy();
  32. this.displayData();
  33. },
  34. //人才政策
  35. getPolicy() {
  36. const category_id = 17
  37. rcpolicy(category_id).then( res => {
  38. this.data = res.data.list
  39. this.$nextTick(() => {
  40. this.getHeight()
  41. })
  42. })
  43. },
  44. //开始循环处理距离事件
  45. displayData() {
  46. this.timeOut = setInterval(() => {
  47. this.conceptMarginTop--
  48. if (this.conceptMarginTop+this.boxHeight <= 0) {
  49. this.conceptMarginTop = 0;
  50. }
  51. },30)
  52. if(this.move) {
  53. clearTimeout(time)
  54. }
  55. },
  56. // 初始化获取栏目高度
  57. getHeight() {
  58. this.boxHeight =( this.$refs.conceptList.clientHeight) / 2
  59. },
  60. stopTimel() {
  61. clearInterval(this.timeOut)
  62. },
  63. // 结束
  64. mousemove() {
  65. this.stopTimel()
  66. },
  67. //开始
  68. mouseout() {
  69. this.displayData()
  70. },
  71. },
  72. }
  73. </script>
  74. <style lang="scss" scoped>
  75. $height: 15px;
  76. .concept {
  77. overflow: hidden;
  78. font-size: 13px;
  79. height: $height*14+25px;
  80. .data {
  81. margin: 5px;
  82. min-height: $height;
  83. overflow: hidden;
  84. text-overflow: ellipsis;
  85. display: -webkit-box;
  86. -webkit-box-orient: vertical;
  87. -webkit-line-clamp: 1;
  88. }
  89. }
  90. </style>