[Vuejs]-Masonry is not a function

0👍

You can get vue component DOM element by this.$el. So you can do the following:

$(this.$el.querySelector('.team')).masonry({
                            columnWidth: '.member',
                            itemSelector: '.member'
                          }); 

But remember this is valid as long as your component is not a Fragment Instance i.e. it has a single root HTML tag.


You many need to put following script line in index.html, so that it loads properly.

<script src="https://unpkg.com/masonry-layout@4.1.1/dist/masonry.pkgd.min.js"></script>

Leave a comment