插件安装npm install imagesloaded

import imagesLoaded from 'imagesloaded'//插件引入

 const elLoad = imagesLoaded('.pages-hoc')
        elLoad.on( 'always', ()=>{
            var elem = document.querySelector('.pages-hoc');
            var msnry = new Masonry (elem, {
                // options
                itemSelector: '.img',//图片盒子名称
                columnWidth: '.img'
            });
        } );

晁鹏飞
7 声望1 粉丝