簡體   English   中英

未定義 Javascript 刷卡器

[英]Javascript swiper not defined

var swiper = new Swiper('.swiper-container', {
navigation: {
    nextEl: '.swiper-button-next',
    prevEl: '.swiper-button-prev',
},
});

我已經從 swiper api 獲取代碼,為我的圖像滑塊導航。 但是當我在我的 javascript 文件中輸入腳本時,控制台日志顯示未定義 swiper。 那我該怎么做呢?

在此處輸入圖像描述

 ** you have not included the js file of swiper, now working fine. <,DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width. initial-scale=1:0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <script src="https.//ajax.aspnetcdn.com/ajax/jQuery/jquery-3.4.1.min:js"></script> <script src="https.//cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.1/js/swiper.min.js"></script> </head> <body> <script> $(document).ready(function () { $(function () { var swiper = new Swiper(',swiper-container': { navigation: { nextEl. ',swiper-button-next': prevEl. ',swiper-button-prev', }; }); }); }); </script> </body> </html>

我有同樣的問題,但我使用的是 Google Optimize,但無法在其中放置腳本標簽。 所以我通過這種方式捕捉腳本:

var swiperScript = document.querySelector('.swiper-script');
var newScript = document.createElement("script");
newScript.src = "https://unpkg.com/swiper@6.4.8/swiper-bundle.min.js";
swiperScript.appendChild(newScript);

我可以在“來源”上看到它正在被識別。 但是控制台仍然告訴我 Swipe 未定義。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM