闫增涛
2024-05-31 72f8190d33b5e6f1b64b848048f315cf530bc6ef
src/books/English/view/components/chapter001.vue
@@ -1812,9 +1812,10 @@
                  </div>
                  <div class="swiper-button-next"></div>
                  <div class="swiper-button-prev"></div>
                  <div class="pageBox"></div>
                </div>
                <!-- 显示当前页和总页数的元素 -->
                <div class="pageBox">{{ pageNum }} / {{ total }}</div>
              </div>
            </div>
          </div>
@@ -2314,23 +2315,7 @@
    showPageList: {
      type: Array,
    },
    pageNum:{
      type:String
    },
    total:{
      type:String
    }
  },
  // watch: {
  //   showPageList: {
  //     handler(newVal, oldVal) {
  //       if (newVal.indexOf(14) > -1) {
  //         console.log("页码", newVal, oldVal);
  //         this.setSwiper();
  //       }
  //     },
  //   },
  // },
  data() {
    return {
      imgThirteen: require("../../assets/images/grammar.jpg"),
@@ -2636,48 +2621,6 @@
    },
    saveData() {
      console.log(this.testData);
    },
    setSwiper() {
      const that = this;
      const dom = document.querySelector(".swiper_ppt");
      console.log("dom", dom);
      new Swiper(dom, {
        loop: false, // 无缝
        autoplay: false,
        paginationClickable: true,
        slidesPerView: 1, // 一组三个
        spaceBetween: 30, // 间隔
        // 如果需要前进后退按钮
        navigation: {
          nextEl: (this.container ? this.container : document).querySelector(
            ".swiper-button-next"
          ),
          prevEl: (this.container ? this.container : document).querySelector(
            ".swiper-button-prev"
          ),
        },
        // 窗口变化,重新init,针对F11全屏和放大缩小,必须加
        observer: true,
        observeParents: true,
        on: {
          slideChange: function (value) {
            console.log("ppt页码", value);
            let currentPage = value.activeIndex + 1; // 获取当前页(从1开始计数)
            let totalPages = value.slides.length; // 获取总页数
            // this.changePage(currentPage)
            that.pageNum = currentPage;
            this.total = totalPages;
            console.log(this.pageNum, this.total);
          },
          // slideChangeTran sitionStart:function (value) {
          //   // 每当滑块改变时触发,更新当前页和总页数的显示
          //   let currentPage = value.activeIndex + 1; // 获取当前页(从1开始计数)
          //   let totalPages = value.slides.length; // 获取总页数
          //   var paginationInfoEl = document.querySelector('.pagination-info');
          //   paginationInfoEl.textContent = currentPage + '/' + totalPages;
          // }
        },
      });
    },
  },
};