未捕获的类型错误:$(...).lightGallery 不是函数 [英] Uncaught TypeError: $(...).lightGallery is not a function

查看:25
本文介绍了未捕获的类型错误:$(...).lightGallery 不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试单击链接时,它会在浏览器控制台中显示:

when I try to click the link it shows this in browser console:

Uncaught TypeError: $(...).lightGallery is not a    function(anonymous function) @ index.html:250dispatch @ jquery.min.js:3r.handle @ jquery.min.js:3

这是我使用的代码:

    $('#gallery').on('click', function() {
    $(this).lightGallery({
        dynamic: true,
        dynamicEl: [{
            "src": 'assets/images/gallery/1.jpg',
            'thumb': 'assets/images/gallery/thumbs/1.jpg',
            'subHtml': '<h4>Fading Light</h4><p>Classic view from Rigwood Jetty on Coniston Water an old archive shot similar to an old post but a little later on.</p>'
        }, {
            'src': 'assets/images/gallery/2.jpg',
            'thumb': 'assets/images/gallery/thumbs/2.jpg',
            'subHtml': "<h4>Bowness Bay</h4><p>A beautiful Sunrise this morning taken En-route to Keswick not one as planned but I'm extremely happy I was passing the right place at the right time....</p>"
        }, {
            'src': 'assets/images/gallery/3.jpg',
            'thumb': 'assets/images/gallery/thumbs/3.jpg',
            'subHtml': "<h4>Coniston Calmness</h4><p>Beautiful morning</p>"
        }]
    })
});

请记住,我在 lightGallery 中使用的是动态模式.

bear in mind I am using the Dynamic Mode in lightGallery.

  1. 我之前已经包含了 lightGallery 库和之前的 jQuery 库.
  2. 我尝试用 jQuery 替换 $.
  3. 我也尝试过分号解决方案",但没有成功.

这是我包含的整个库:

    <script src="assets/web/assets/jquery/jquery.min.js"></script>
  <script src="assets/tether/tether.min.js"></script>
  <script src="assets/bootstrap/js/bootstrap.min.js"></script>
  <script src="assets/smooth-scroll/SmoothScroll.js"></script>
  <script src="assets/viewportChecker/jquery.viewportchecker.js"></script>
  <script src="assets/cookies-alert-plugin/cookies-alert-core.js"></script>
  <script src="assets/cookies-alert-plugin/cookies-alert-script.js"></script>
  <script src="assets/dropdown/js/script.min.js"></script>
  <script src="assets/touchSwipe/jquery.touchSwipe.min.js"></script>
  <script src="assets/jarallax/jarallax.js"></script>
  <script src="assets/bootstrap-carousel-swipe/bootstrap-carousel-swipe.js"></script>
  <script src="assets/jquery-mb-ytplayer/jquery.mb.YTPlayer.min.js"></script>
  <script src="assets/theme/js/script.js"></script>
  <script src="assets/mobirise-slider-video/script.js"></script>
  <script src="assets/formoid/formoid.min.js"></script>
  <!-- lightgallery -->
  <script src="assets/theme/js/lightgallery.min.js"></script>
  <script src="assets/theme/js/lg-thumbnail.min.js"></script>
  <script src="assets/theme/js/lg-fullscreen.min.js"></script>
  <script src="assets/theme/js/lg-share.min.js"></script>
  <script src="assets/theme/js/lg-zoom.min.js"></script>
  <script src="assets/theme/js/lg-autoplay.min.js"></script>

推荐答案

Woooooooooooo Haaaaaa 我终于解决了,问题可能出在我的本地版本上!!当我切换到 cdnjs 版本时,它完美运行!!!非常感谢你们所有人!!我所做的就是用cdn链接替换本地的

Wooooooooooo Haaaaaa I finally solved it, and the problem was maybe with local version I have!! When I switched to the cdnjs version it worked PERFECT!!! a huge THANKS for all of you!! all I did is replace the local ones with the cdn links

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.3.2/css/lightgallery.css" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.3.2/js/lightgallery.js"></script>

这篇关于未捕获的类型错误:$(...).lightGallery 不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆