我正在使用 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'
});
});
关于javascript - 宏伟的弹出窗口不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21179828/