javascript ImageLoaded with Masonry, Object #<Object> 没有方法 'imagesLoaded'

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17810400/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 09:43:10  来源:igfitidea点击:

ImagesLoaded with Masonry, Object #<Object> has no method 'imagesLoaded'

javascriptjqueryjquery-pluginsfrontend

提问by Chris

Getting this error, trying to use Masonry with imageLoaded:

收到此错误,尝试将 Masonry 与 imageLoaded 一起使用:

"Object # has no method 'imagesLoaded'"

“对象 # 没有方法 'imagesLoaded'”

The links to the necessary scripts are in my header:

必要脚本的链接在我的标题中:

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script><script src="/js/masonry.pkgd.min.js" type="text/javascript"></script>
<script src="/js/imagesloaded.pkgd.min.js" type="text/javascript"></script>

And here is how the code looks in my footer:

下面是代码在我的页脚中的外观:

$(document).ready(function() {
    $('#archive-post-container').imagesLoaded(function() {
        $(this).masonry({
            itemSelector : '.post',
            columnWidth:344
        });
    });
});

EDIT / ADDENDUM: Placing the script tags for ImagesLoaded and Masonry in the actual .php file for the page I need them on, instead of in header.php gets me this error instead, coming from ImagesLoaded: Uncaught TypeError: undefined is not a function

编辑/附录:将 ImagesLoaded 和 Masonry 的脚本标签放置在我需要它们的页面的实际 .php 文件中,而不是在 header.php 中让我得到这个错误,来自 ImagesLoaded: Uncaught TypeError: undefined is not a function

Not sure why moving the tags just from the to just under the header would change this, but at least now I am getting to imagesLoaded?

不知道为什么将标签从标题下方移动到正下方会改变这一点,但至少现在我开始使用imagesLoaded?

回答by Jeremy Burton

Note that ImagesLoaded is no longer included in the latest Masonry distribution, per

请注意,ImageLoaded 不再包含在最新的 Masonry 发行版中,每个

http://masonry.desandro.com/appendix.html#upgrading-from-v2

http://masonry.desandro.com/appendix.html#upgrading-from-v2

You can get it directly here:

你可以直接在这里得到它:

http://desandro.github.io/imagesloaded/

http://desandro.github.io/imagesloaded/