admin管理员组文章数量:1023213
I have written code for thumbnail slider following an example in the following link splidejs/getting-started for primary slider. Tried to look again and again but I don't see anything in the output even pictures are not shown. Header files already linked through CDN(CSS and js)
Below is the code:
HEADER FILES
<link rel="stylesheet" href="/@splidejs/splide@latest/dist/css/splide.min.css">
<script type="text/javascript" src="catalog.js"></script>
<link rel="stylesheet" type="text/css" href="catalog.css">
JS HEADER FILE
<script src="/@splidejs/splide@latest/dist/js/splide.min.js"></script>
<script src="/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
HTML CODE
<div class="splide">
<div class="splide__track">
<ul class="splide__list">
<li class="splide__slide"><img src="pic2.jpg"></li>
<li class="splide__slide"><img src="pic1.jfif"></li>
<li class="splide__slide"><img src="">pic.png</li>
</ul>
</div>
</div>
JAVASCRIPT CODE
document.addEventListener("DOMContentLoaded", function () {
new Splide("#secondary-slider", {
fixedWidth: 100,
height: 60,
gap: 10,
rewind: true,
cover: true,
pagination: false,
}).mount();
});
I have written code for thumbnail slider following an example in the following link splidejs./getting-started for primary slider. Tried to look again and again but I don't see anything in the output even pictures are not shown. Header files already linked through CDN(CSS and js)
Below is the code:
HEADER FILES
<link rel="stylesheet" href="https://cdn.jsdelivr/npm/@splidejs/splide@latest/dist/css/splide.min.css">
<script type="text/javascript" src="catalog.js"></script>
<link rel="stylesheet" type="text/css" href="catalog.css">
JS HEADER FILE
<script src="https://cdn.jsdelivr/npm/@splidejs/splide@latest/dist/js/splide.min.js"></script>
<script src="https://cdn.jsdelivr/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
HTML CODE
<div class="splide">
<div class="splide__track">
<ul class="splide__list">
<li class="splide__slide"><img src="pic2.jpg"></li>
<li class="splide__slide"><img src="pic1.jfif"></li>
<li class="splide__slide"><img src="">pic.png</li>
</ul>
</div>
</div>
JAVASCRIPT CODE
document.addEventListener("DOMContentLoaded", function () {
new Splide("#secondary-slider", {
fixedWidth: 100,
height: 60,
gap: 10,
rewind: true,
cover: true,
pagination: false,
}).mount();
});
Share
Improve this question
edited Jan 17, 2024 at 23:13
Roko C. Buljan
207k41 gold badges328 silver badges340 bronze badges
asked Dec 16, 2020 at 4:35
Kelvin MgayaKelvin Mgaya
691 gold badge2 silver badges9 bronze badges
8
- Why do you attach the same event twice to document? – Ryan Wilson Commented Dec 17, 2020 at 4:34
- I just copied from the above link, I made a mistake but after removing the error still remain – Kelvin Mgaya Commented Dec 17, 2020 at 4:45
- if it's undefined, I imagine there is an error in how you are importing the files. Add your headers to your post so people can check your imports – Ryan Wilson Commented Dec 17, 2020 at 4:52
- 1 Can you please add all of your headers which includes all js, because I can not see any slider JS file here – Swaraj Gandhi Commented Dec 17, 2020 at 5:07
- 1 I see a Splide css file but no JavaScript file import – Ryan Wilson Commented Dec 17, 2020 at 5:07
2 Answers
Reset to default 0From what I see in your javascript code you are trying to mount Splide on "#secondary-slider" but I can't see this id in your HTML. Try fixing this with either adding an a corresponding id property to your div with with class "splide" or call Splide mount on ".splide"
Call JS after the HTML code:
<script src="https://cdn.jsdelivr/npm/@splidejs/[email protected]/dist/js/splide.min.js"></script>
new Splide('.splide').mount();
</script>
Should work https://github./Splidejs/splide/issues/9#issuement-573321831 This helped me.
I have written code for thumbnail slider following an example in the following link splidejs/getting-started for primary slider. Tried to look again and again but I don't see anything in the output even pictures are not shown. Header files already linked through CDN(CSS and js)
Below is the code:
HEADER FILES
<link rel="stylesheet" href="/@splidejs/splide@latest/dist/css/splide.min.css">
<script type="text/javascript" src="catalog.js"></script>
<link rel="stylesheet" type="text/css" href="catalog.css">
JS HEADER FILE
<script src="/@splidejs/splide@latest/dist/js/splide.min.js"></script>
<script src="/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
HTML CODE
<div class="splide">
<div class="splide__track">
<ul class="splide__list">
<li class="splide__slide"><img src="pic2.jpg"></li>
<li class="splide__slide"><img src="pic1.jfif"></li>
<li class="splide__slide"><img src="">pic.png</li>
</ul>
</div>
</div>
JAVASCRIPT CODE
document.addEventListener("DOMContentLoaded", function () {
new Splide("#secondary-slider", {
fixedWidth: 100,
height: 60,
gap: 10,
rewind: true,
cover: true,
pagination: false,
}).mount();
});
I have written code for thumbnail slider following an example in the following link splidejs./getting-started for primary slider. Tried to look again and again but I don't see anything in the output even pictures are not shown. Header files already linked through CDN(CSS and js)
Below is the code:
HEADER FILES
<link rel="stylesheet" href="https://cdn.jsdelivr/npm/@splidejs/splide@latest/dist/css/splide.min.css">
<script type="text/javascript" src="catalog.js"></script>
<link rel="stylesheet" type="text/css" href="catalog.css">
JS HEADER FILE
<script src="https://cdn.jsdelivr/npm/@splidejs/splide@latest/dist/js/splide.min.js"></script>
<script src="https://cdn.jsdelivr/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
HTML CODE
<div class="splide">
<div class="splide__track">
<ul class="splide__list">
<li class="splide__slide"><img src="pic2.jpg"></li>
<li class="splide__slide"><img src="pic1.jfif"></li>
<li class="splide__slide"><img src="">pic.png</li>
</ul>
</div>
</div>
JAVASCRIPT CODE
document.addEventListener("DOMContentLoaded", function () {
new Splide("#secondary-slider", {
fixedWidth: 100,
height: 60,
gap: 10,
rewind: true,
cover: true,
pagination: false,
}).mount();
});
Share
Improve this question
edited Jan 17, 2024 at 23:13
Roko C. Buljan
207k41 gold badges328 silver badges340 bronze badges
asked Dec 16, 2020 at 4:35
Kelvin MgayaKelvin Mgaya
691 gold badge2 silver badges9 bronze badges
8
- Why do you attach the same event twice to document? – Ryan Wilson Commented Dec 17, 2020 at 4:34
- I just copied from the above link, I made a mistake but after removing the error still remain – Kelvin Mgaya Commented Dec 17, 2020 at 4:45
- if it's undefined, I imagine there is an error in how you are importing the files. Add your headers to your post so people can check your imports – Ryan Wilson Commented Dec 17, 2020 at 4:52
- 1 Can you please add all of your headers which includes all js, because I can not see any slider JS file here – Swaraj Gandhi Commented Dec 17, 2020 at 5:07
- 1 I see a Splide css file but no JavaScript file import – Ryan Wilson Commented Dec 17, 2020 at 5:07
2 Answers
Reset to default 0From what I see in your javascript code you are trying to mount Splide on "#secondary-slider" but I can't see this id in your HTML. Try fixing this with either adding an a corresponding id property to your div with with class "splide" or call Splide mount on ".splide"
Call JS after the HTML code:
<script src="https://cdn.jsdelivr/npm/@splidejs/[email protected]/dist/js/splide.min.js"></script>
new Splide('.splide').mount();
</script>
Should work https://github./Splidejs/splide/issues/9#issuement-573321831 This helped me.
本文标签: javascriptUncaught ReferenceErrorSplide is not defined at HTMLDocumentStack Overflow
版权声明:本文标题:javascript - Uncaught ReferenceError, Splide is not defined at HTMLDocument - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745542731a2155257.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论