[英]$ is not defined lightgallery
For some reason my lightgallery is not working.出于某种原因,我的灯廊无法正常工作。 I added it the same way I always do and all javascript files are included after Jquery.
我以与往常相同的方式添加它,并且所有 javascript 文件都包含在 Jquery 之后。
I get this message in the console:我在控制台中收到此消息:
Uncaught TypeError: $ is not a function
at product-1.html:433
(anonymous) @ product-1.html:433
Which points to:其中指出:
<script type="text/javascript">
$(document).ready(function($) {
$("#lightgallery").lightGallery();
});
</script>
All files are correctly loaded, I checked in the network tab.所有文件都已正确加载,我检查了网络选项卡。
What could be the problem and how can I fix it?可能是什么问题,我该如何解决? Maybe there is a conflict somewhere?
也许某处有冲突? Can I wrap it in a function to make it work?
我可以将它包装在一个函数中以使其工作吗?
My js files:我的js文件:
in the head在头上
<link href="https://cdn.rawgit.com/sachinchoolur/lightgallery.js/master/dist/css/lightgallery.css" rel="stylesheet">
your html content你的html内容
<div id="lightgallery">
<a href="img/img1.jpg">
<img src="img/thumb1.jpg" />
</a>
<a href="img/img2.jpg">
<img src="img/thumb2.jpg" />
</a>
</div>
in the body include light gallery js files after jquery在主体中包含 jquery 之后的灯光画廊 js 文件
<script src="https://cdn.rawgit.com/sachinchoolur/lightgallery.js/master/dist/js/lightgallery.js"></script>
<script src="https://cdn.rawgit.com/sachinchoolur/lg-pager.js/master/dist/lg-pager.js"></script>
<script src="https://cdn.rawgit.com/sachinchoolur/lg-autoplay.js/master/dist/lg-autoplay.js"></script>
<script src="https://cdn.rawgit.com/sachinchoolur/lg-fullscreen.js/master/dist/lg-fullscreen.js"></script>
<script src="https://cdn.rawgit.com/sachinchoolur/lg-zoom.js/master/dist/lg-zoom.js"></script>
<script src="https://cdn.rawgit.com/sachinchoolur/lg-hash.js/master/dist/lg-hash.js"></script>
<script src="https://cdn.rawgit.com/sachinchoolur/lg-share.js/master/dist/lg-share.js"></script>
<script>
lightGallery(document.getElementById('lightgallery'));
</script>
This really works for me.这真的对我有用。
Clearing browser cache may help sometimes.清除浏览器缓存有时可能会有所帮助。 Or narrow down your problem by loading one by one starting with jquery.
或者通过从 jquery 开始一一加载来缩小您的问题。
This solves the problem :这解决了这个问题:
<script>
lightGallery(document.getElementById('lightgallery'));
</script>
1. 检查你的地图 api js 链接,如https://developers.google.com/maps/api/js这是否正确 2. 同时按下 Ctrl + Shift + Del按钮并清除缓存和 cookie
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.