| | |
| | | </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> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import getResourcePath from "@/assets/methods/resources"; |
| | | import Swiper from "swiper/bundle"; |
| | | import "swiper/swiper-bundle.css"; |
| | | import {getResourcePath} from "@/assets/methods/resources"; |
| | | export default { |
| | | name: "chapter-one", |
| | | props: { |
| | | showPageList: { |
| | | type: Array, |
| | | }, |
| | | }, |
| | | watch: { |
| | | showPageList: { |
| | | handler(newVal, oldVal) { |
| | | if (newVal.indexOf(14) > -1) { |
| | | console.log("页码", newVal, oldVal); |
| | | this.setSwiper(); |
| | | } |
| | | }, |
| | | }, |
| | | }, |
| | | data() { |
| | |
| | | showAnswerFive: false, |
| | | showImg: false, |
| | | showQuestionAnswer: false, |
| | | pageNum: "1", |
| | | total: "27", |
| | | // pageNum: "1", |
| | | // total: "27", |
| | | questionData: { |
| | | warnUp: { |
| | | one: { |
| | |
| | | }, |
| | | 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; |
| | | // } |
| | | }, |
| | | }); |
| | | }, |
| | | changePage(value) { |
| | | this.pageNum = value; |
| | | }, |
| | | }, |
| | | }; |