繁体   English   中英

巨大的弹出窗口不起作用

[英]magnific popup not working

我正在使用Magnific Popup。

$(document).ready(function() {
  $('.image-viewer').magnificPopup({
      type: 'ajax'
  });
});

这是html:

<a href="/site-media/{{ photo.image }}" class="image-viewer"><img class="fest-content-event-content-photo" width = "100%" src="/site-media/{{ photo.thumbnail2 }}" /></a>

但是,它不起作用,控制台显示错误:

 Uncaught TypeError: Property '$' of object [object Object] is not a function (index):30
(anonymous function) (index):30
fire jquery.js:3048
self.fireWith jquery.js:3160
jQuery.extend.ready jquery.js:433
completed

怎么了? 我没有加载tje jquery.js文件两次。

首先,确保您已正确包含jQuery库:

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

其次,也许jQuery与其他库之间存在冲突,您可以尝试使用:

jQuery(document).ready(function ($) {
     $('.image-viewer').magnificPopup({
          type: 'ajax'
     });
});

听起来你有冲突..尝试在document.ready函数中添加$

$(document).ready(function($) {
  $('.image-viewer').magnificPopup({
      type: 'ajax'
  });
});

或者用jQuery替换$

jQuery(document).ready(function(){
      jQuery('.image-viewer').magnificPopup({
          type: 'ajax'
      });
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM