簡體   English   中英

視頻庫得到 Uncaught TypeError: $(...).lightGallery is not a function

[英]video gallery getting Uncaught TypeError: $(...).lightGallery is not a function

我正在為我的視頻庫使用 video.js。 我嘗試了 video.js,但收到以下錯誤消息。

未捕獲的類型錯誤:$(...).lightGallery 不是函數我的代碼:

<html>
<head>
    <link href="http://vjs.zencdn.net/4.12/video-js.css" rel="stylesheet">
    <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script src="http://vjs.zencdn.net/4.12/video.js"></script>
</head>

<body>
    <!-- Hidden video div -->
    <div style="display:none;" id="video1">
        <video class="lg-video-object lg-html5 video-js vjs-default-skin" controls preload="none">
            <source src="videos/test1.mp4" type="video/mp4">
             Your browser does not support HTML5 video.
        </video>
    </div>
    <div style="display:none;" id="video2">
        <video class="lg-video-object lg-html5 video-js vjs-default-skin" controls preload="none">
            <source src="videos/test2.mp4" type="video/mp4">
             Your browser does not support HTML5 video.
        </video>
    </div>

    <!-- data-src should not be provided when you use html5 videos -->
    <ul id="video-gallery">
      <li data-poster="video-poster1.jpg" data-sub-html="video caption1" data-html="#video1" >
          <img src="1.jpg" />
      </li>
      <li data-poster="video-poster2.jpg" data-sub-html="video caption2" data-html="#video2" >
          <img src="2.jpg" />
      </li>
      ...
    </ul>


</body>
<script>
    $('#video-gallery').lightGallery({
        videojs: true
    }); 

</script>

</html>

請提出解決方案。

您似乎缺少 lightgallery 的腳本標簽

<script src="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.2.4/js/lightgallery.min.js"></script>
    $(document).ready(function() {    
        $('#video-gallery').lightGallery({
            videojs: true
        }); 
    });

奇怪的事情,但當前版本只能以這種方式初始化(​​典型的 JQuery 語法不起作用):

lightGallery($('#video-thumbnails')[0], {
    download: false,
    //other options
});

甚至在 Github 上也有打開的問題: https : //github.com/sachinchoolur/lightgallery.js/issues/42

暫無
暫無

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

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