HotScrollBar.vue 1.88 KB
<template>
  <van-notice-bar class="hot-scroll-bar" :scrollable="false">
    <template #left-icon>
      <img class="title-icon" src="@/assets/icon/icon_today_hot.png" alt="" />
      <span class="line"></span>
    </template>
    <van-swipe
      vertical
      class="notice-swipe"
      :autoplay="3000"
      :show-indicators="false"
    >
      <van-swipe-item v-for="(item, idx) in data.scrollBarVOS" :key="idx">
        <div class="content-main">
          <span class="tag" :style="tagStyle(item)">{{ item.scrollTag }}</span>
          <span class="content">{{ item.scrollTitle }}</span>
        </div>
      </van-swipe-item>
    </van-swipe>
  </van-notice-bar>
</template>

<script>
export default {
  name: 'HotScrollBar',
  props: {
    data: {
      type: Object,
      default: () => { return {} }
    }
  },
  methods: {
    tagStyle (item) {
      const { backgroundColor = 'red' } = item || {}
      return { backgroundColor: 'red' }
    }
  }
}
</script>

<style lang="less" scoped>
@import '~@/assets/css/mixins.less';
.hot-scroll-bar {
  margin-top: 20px;
  height: 45px;
  display: flex;
  align-items: center;
  background: white;
  border-radius: 8px;
  border: 2px solid rgba(240, 241, 243, 1);
  padding: 0 10px;
  .title-icon {
    width: 35px;
    height: 35px;
  }

  .line {
    width: 1px;
    height: 20px;
    background: #000000;
    opacity: 0.1;
    margin-left: 11px;
  }

  .notice-swipe {
    height: 45px;
    line-height: 45px;
    padding-left: 8px;
  }

  .content-main {
    width: 100%;
    display: flex;
    align-items: center;
    .tag {
      color: white;
      border-radius: 4px;
      padding: 0 3px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 19px;
      height: 20px;
    }
    .content {
      height: 100%;
      color: #333333;
      font-size: 16px;
      margin-left: 5px;
      .line-clamp(1);
    }
  }
}
</style>