ImagesLoaded with Masonry, Object #<Object>没有方法“imagesLoaded"

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

Getting this error, trying to use Masonry with imageLoaded:

对象#没有方法'imagesLoaded'"

"Object # has no method '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
        });
    });
});

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

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?

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?

推荐答案

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

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

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

你可以直接在这里获取:

You can get it directly here:

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

相关文章