angularjs passy masonry - TypeError:element.masonry不是函数

时间:2015-04-22 09:10:05

标签: angularjs masonry

我使用passy砌体时遇到此错误。任何想法是什么意思?因为现在基本上砖石砌体对我来说根本不起作用。

提前致谢

3 个答案:

答案 0 :(得分:4)

我不确定你的问题的原因是什么,但我只是在处理同样的事情,我能够通过搞乱依赖来解决它。经过一些反复试验,我注意到我错过了一个角度砌体的依赖关系,称为jquery-bridget。我不知道为什么没有安装bower-install,也许bower.json存在问题,但无论如何,如果你这样做

bower uninstall --save angular-masonry

然后

bower install --save jquery-bridget
bower install --save angular-masonry

它可以解决你的问题。再一次,不完全确定这是否是同一个问题,或者我的设置是否有什么东西让我搞砸了。希望这有帮助!

答案 1 :(得分:2)

您需要安装jquery bridget插件:

bower install --save jquery-bridget

如果您使用grunt-wiredep,那么您应该在html中获得以下脚本顺序(脚本列表的第二部分应该具有完全相同的顺序:jquery.bridget.js然后其他脚本!):

<!-- bower:js -->
<script src="/vendor/jquery/dist/jquery.js"></script>
<script src="/vendor/angular/angular.js"></script>
<script src="/vendor/angular-resource/angular-resource.js"></script>
<script src="/vendor/angular-route/angular-route.js"></script>

<script src="/vendor/jquery-bridget/jquery.bridget.js"></script>
<script src="/vendor/get-style-property/get-style-property.js"></script>
<script src="/vendor/get-size/get-size.js"></script>
<script src="/vendor/eventie/eventie.js"></script>
<script src="/vendor/doc-ready/doc-ready.js"></script>
<script src="/vendor/eventEmitter/EventEmitter.js"></script>
<script src="/vendor/matches-selector/matches-selector.js"></script>
<script src="/vendor/outlayer/item.js"></script>
<script src="/vendor/outlayer/outlayer.js"></script>
<script src="/vendor/masonry/masonry.js"></script>
<script src="/vendor/imagesloaded/imagesloaded.js"></script>
<script src="/vendor/angular-masonry/angular-masonry.js"></script>
<!-- endbower -->

这是 bower.json 文件的一部分:

{
  ...
  "dependencies": {
    "jquery": "~2.1.4",
    "angular": "~1.3.15",
    "angular-resource": "~1.3.15",
    "angular-route": "~1.3.15",
    "angular-masonry": "~0.11.0",
    "jquery-bridget": "~1.1.0"
  }
}

通过所有这些配置,angurlar-masonry正在按预期工作。

答案 2 :(得分:2)

之前我遇到了完全相同的问题,并通过更改“jquery.bridget.js”加载位置解决了问题。

<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-animate/angular-animate.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>

<script src="bower_components/jquery-bridget/jquery.bridget.js"></script>

<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-touch/angular-touch.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="bower_components/angular-local-storage/dist/angular-local-storage.js"></script>
<script src="bower_components/get-style-property/get-style-property.js"></script>
<script src="bower_components/get-size/get-size.js"></script>
<script src="bower_components/eventie/eventie.js"></script>
<script src="bower_components/doc-ready/doc-ready.js"></script>
<script src="bower_components/eventEmitter/EventEmitter.js"></script>
<script src="bower_components/matches-selector/matches-selector.js"></script>
<script src="bower_components/outlayer/item.js"></script>
<script src="bower_components/outlayer/outlayer.js"></script>
<script src="bower_components/masonry/masonry.js"></script>
<script src="bower_components/imagesloaded/imagesloaded.js"></script>
<script src="bower_components/angular-masonry/angular-masonry.js"></script>
<!-- endbower -->