标签 javascript 下的文章

html代码

    <div class="swiper-container">
        <div class="swiper-wrapper">
            <div class="swiper-slide">Slide 1</div>
            <div class="swiper-slide">Slide 2</div>
            <div class="swiper-slide">Slide 3</div>
            <div class="swiper-slide">Slide 4</div>
            <div class="swiper-slide">Slide 5</div>
            <div class="swiper-slide">Slide 6</div>
            <div class="swiper-slide">Slide 7</div>
            <div class="swiper-slide">Slide 8</div>
            <div class="swiper-slide">Slide 9</div>
            <div class="swiper-slide">Slide 10</div>
        </div>
    </div>

js代码

    <script>
var mySwiper = new Swiper('.swiper-container', {
            onTouchEnd: function(swiper, event) {
                console.log('onTouchEnd' + swiper.swipeDirection);

                if (swiper.isBeginning && swiper.swipeDirection == "prev") {
                    console.log("上一页")
                    location.href = "https://www.liugang.net/about.html";

                }
                if (swiper.isEnd && swiper.swipeDirection == "next") {
                    console.log("下一页")
                    location.href = "https://www.liugang.net/";

                }
            }
        }
    </script>