尝试在项目中使用klederson的Angular Masonry Directive,但无法使其工作。空间被占用元素的body标签,但它们不可见,上面提到的错误显示在控制台中。
注入砌体依赖性:
angular.module("cardSite",['masonry'])
标记我正在使用调用砌体。每当我尝试JS方式时,我都会遇到同样的错误。
<div masonry='{ "transitionDuration" : "0.4s" , "itemSelector" : ".grid-item"}' class="grid">
<div masonry-tile class="grid-item">...</div>
<div masonry-tile class="grid-item grid-item--width2">...</div>
<div masonry-tile class="grid-item--height2">...</div>
<div masonry-tile class="grid-item">...</div>
<div masonry-tile class="grid-item">...</div>
<div masonry-tile class="grid-item grid-item--width2">...</div>
<div masonry-tile class="grid-item--height2"></div>
<div masonry-tile class="grid-item">...</div>
<div masonry-tile class="grid-item">...</div>
<div masonry-tile class="grid-item grid-item--width2">...</div>
<div masonry-tile class="grid-item">...</div>
<div masonry-tile class="grid-item">...</div>
<div masonry-tile class="grid-item--height2"></div>
<div masonry-tile class="grid-item grid-item--width2">...</div>
<div masonry-tile class="grid-item">...</div>
<div masonry-tile class="grid-item--height2"></div>
<div masonry-tile class="grid-item">...</div>
<div masonry-tile class="grid-item grid-item--width2">...</div>
<div masonry-tile class="grid-item">...</div>
</div>
调用页面底部的脚本:
<script src="scripts/directives/angular-masonry-directive.js"></script>
相关网页的网址: http://marcmurray.net/test_sites/card_site/index.html
错误图片: http://i.imgur.com/G9GVrYR.png
Plunker: https://plnkr.co/edit/vzhUUtKtrZWxCwMITOL6?p=preview
答案 0 :(得分:2)
错误显示ReferenceError: Masonry is not defined
- 因此问题与directive
无关 - 因为Masonry()
不存在 - 我想你和我#39;重新找不到http://masonry.desandro.com/
问题在于:var masonry = scope.masonry = new Masonry(container, options);