1
スワイパープラグインを使用していますが、動作する方法はありません。スワイパー - 方法は機能しません - mySwiper.slideToは機能ではありません
私のjQueryとswiperは次のように追加されます。私のhtmlの下部に
<script src="jquery-3.2.1.min.js" type="text/javascript"></script>
<script src="swiper.jquery.js" type="text/javascript">
。 私swiperが文書準備に次のように初期化されます:
mySwiper = new Swiper('.swiper-container', {
direction: 'horizontal',
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
pagination: '.swiper-pagination',
paginationType: 'fraction',
grabCursor: true,
keyboardControl: true,
onSlideChangeStart: function(){
$('video').each(function() {
$(this)[0].pause();
});
$(".swiper-slide-active video").each(function() {
$(this)[0].play();
});
if ($(".swiper-slide-active").hasClass("layout4"))
{
video_visible = 1;
$(".section").css("background-color", "black");
$("body").css("color", "white");
$(".swiper-button-prev").css("background-image", "url(img/leftArrowW.png)");
$(".swiper-button-next").css("background-image", "url(img/rightArrowW.png)");
$(".swiper-button-prev").css("opacity", "0.25");
$(".swiper-button-next").css("opacity", "0.25");
$(".headline").css("opacity", "0.25");
$(".swiper-pagination").css("opacity", "0.25");
}
else {
video_visible = 0;
$(".section").css("background-color", "white");
$("body").css("color", "black");
$(".section .swiper-button-prev").css("background-image", "url(img/leftArrow.png)");
$(".section .swiper-button-next").css("background-image", "url(img/rightArrow.png)");
$(".swiper-button-prev").css("opacity", "1");
$(".swiper-button-next").css("opacity", "1");
$(".headline").css("opacity", "1");
$(".swiper-pagination").css("opacity", "1");
}
if ($(".swiper-slide-active").hasClass("layout7"))
{
$(".layout7").css("background-color", "#e0e8eb");
}
},
loop: true ,
});
と私は呼びたい機能は次のとおりです。
$('.section .down').waypoint(function(direction){
if ($(".swiper-slide-active").hasClass("layout4")){
if (direction == 'down') {
if (!once_d){
mySwiper.slideTo(1,100,false);
$(".section").css("background-color", "white");
$("body").css("color", "black");
$(".swiper-button-prev").css("background-image", "url(img/leftArrow.png)");
$(".swiper-button-next").css("background-image", "url(img/rightArrow.png)");
$(".swiper-button-prev").css("opacity", "1");
$(".swiper-button-next").css("opacity", "1");
$(".headline").css("opacity", "1");
$(".swiper-pagination").css("opacity", "1");
$('video').each(function() {
$(this)[0].pause();
});
video_visible = 0;
once_d = true;
}
else{
return;
}
}
}
}, { offset: "-25%" });
私が手にエラーがある:
Uncaught TypeError: mySwiper.slideTo is not a function
at Waypoint.$.waypoint.offset [as callback]
この問題が発生し、どんなメソッドを実行しようとしているに関係なく。試しました
mySwiper.update();
も同様です。
私のswiper/jQueryファイルからエラーが発生する可能性がありますが、私もredownloadingを試みました。事前
スワイア変数が作成される前に実行するのを避けるために、あなたのウェイポイントもdocument.ready内で初期化されていますか?あなたのウェイポイント・コールの中で 'console.log(mySwiper)'を実行すると、コンソールに何かが出るのですか、それともmySwiperは未定義ですか? – delinear
私はmethodeコールの直前にconsole.log(mySwiper)を追加しました。 (2)[Swiper、Swiper] –
これは恐らくあなたがスワイプオブジェクトの配列を取得していることを意味します。脇の $( 'ビデオ')。それぞれ(function(){ $(this)[0] .pause(); });唯一のことが[0]インデックスであれば、$( 'video')[0] .pause()または$( 'video')を実行することができます。 (0).pause();スクリプトが将来のコードでエラーを起こす可能性がほとんどないためです。 – Ezekiel