[英]Javascript swiper not defined
** 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.