vue新聞公告效果

image.png
  • 新聞公告,動態(tài)切換展示
 <div class="xinwen">
      <div class="swiper-container">
        <div class="swiper-wrapper">
          <div v-for="item in list" class="swiper-slide">
            <img :src="item.imageUrl" />
          </div>
        </div>
      </div>
      <div class="paginationbox"></div>
      <div class="pagination" @swiper="onSlideChangeStart">
      </div>
      <ul class="caption">
        <li :class="{ active: sign == '1' }">
          中國之美|你的笑臉如期到來,這正是成長的意義
        </li>
        <li :class="{ active: sign == '2' }">國家相冊:迎新的日子</li>
        <li :class="{ active: sign == '3' }">習近平的2016(拾貳月)</li>
        <li :class="{ active: sign == '4' }">雕刻家</li>
        <li :class="{ active: sign == '5' }">
          中國之美|你的笑臉如期到來,這正是成長的意義
        </li>
        <li :class="{ active: sign == '6' }">美麗的夜色</li>
      </ul>
    </div>
 sign: "1",
 list: [
        {
          imageUrl: require("@/assets/images/zsk-banner.png"),
        },
        {
          imageUrl: require("@/assets/images/tsc-banner.png"),
        },
        {
          imageUrl: require("@/assets/images/znt-banner.png"),
        },
      ],

  mounted() {
    let mySwiper = new Swiper(".swiper-container", {
      // speed: 100,
      loop: true,
      autoplay: {
        delay: 5000,
        disableOnInteraction: false,
      },
      // speed:500,
      spaceBetween: 30,
      effect: "fade",
      // touchRatio: 10,
      pagination: {
        el: ".pagination",
        clickable: true, // 可點擊
        renderBullet: function (index, className) {
          return '<span class="' + className + '">' + (index + 1) + "</span>";
        },
      },
    });
    let that = this;
    mySwiper.on("paginationUpdate", function () {
      that.sign = mySwiper.realIndex + 1;
      // 在這里執(zhí)行你的代碼
    });
    mySwiper.el.onmouseover = function () {
      mySwiper.autoplay.stop();
    };
    mySwiper.el.onmouseleave = function () {
      mySwiper.autoplay.start();
    };
  },
 onSlideChangeStart(swiper) {
      swiper.pagination.on("update", () => {
        const activeIndex = swiper.activeIndex; // 獲取當前激活的slide索引
        const slidesLength = swiper.slides.length; // 獲取總的slide數量
      });
    },
.xinwen {
  background: #222;
  margin: 0 auto;
  width: 655px;
  height: 441px;
  position: relative;
}

.swiper-container {
  width: 655px;
  height: 441px;
}
.paginationbox {
  width: 100%;
  background: #ececec;
  z-index: 19;
  height: 50px;
  position: absolute;
  bottom: 0px;
  opacity: 0.7;
}
.caption {
  position: absolute;
  bottom: 0px;
  line-height: 34px;
  width: 80%;
  overflow: hidden;
  height: 50px;
  z-index: 20;
  color: #222;
}
.pagination {
  position: absolute;
  right: 0;
  width: 20%;
  z-index: 20;
  bottom: 10px;
  text-align: center;
}

.caption li {
  padding-left: 30px;
  width: 100%;
  position: absolute;
  bottom: -50px;
  transition: all 0.5s cubic-bezier(0.33, 0, 0.2, 1);
}

.caption .active {
  bottom: 8px;
}

.caption li a {
  color: #fff;
  font-size: 16px;
  font-family: microsoft yahei;
  text-decoration: none;
}

?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容