pep*_*epe 2 javascript jquery typeerror referenceerror jquery-masonry
我使用Vanilla Masonry(原始JS,非jQuery版本)如下:
在头部:
<script id="masonry" type="text/javascript" src="resources/js/masonry.js"></script>
Run Code Online (Sandbox Code Playgroud)
身体:
<script>
window.onload = function() {
var wall = new Masonry( document.getElementById('ext-component-3'), {
columnWidth: 145
});
};
</script>
Run Code Online (Sandbox Code Playgroud)
但我一直在:
Uncaught ReferenceError: Masonry is not defined
Uncaught TypeError: Cannot call method 'appendChild' of undefined
Run Code Online (Sandbox Code Playgroud)
有谁知道我的设置有什么问题?
我看了一下masonry.js代码.
您需要将对砌体文件的引用移动到页面底部(在关闭正文标记之前).
或者至少在开口身体标签下方.
它试图将theChild附加到未加载到头部的body标签.