我正在实施wp主题的砌体。使用npm安装了https://masonry.desandro.com/。路径正确。 jQuery之后导入到js文件。但是遇到以下错误。预先感谢。
Uncaught TypeError: jquery__WEBPACK_IMPORTED_MODULE_0___default(...)(...).masonry is not a function
at HTMLDocument.<anonymous> (bundle.js:8)
at i (jquery.js?ver=1.12.4:2)
at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4:2)
at Function.ready (jquery.js?ver=1.12.4:2)
at HTMLDocument.K (jquery.js?ver=1.12.4:2)
(anonymous) @ bundle.js:8
i @ jquery.js?ver=1.12.4:2
fireWith @ jquery.js?ver=1.12.4:2
ready @ jquery.js?ver=1.12.4:2
K @ jquery.js?ver=1.12.4:2
*********在我的js文件中************
import $ from "jquery";
import "masonry-layout";
$(document).ready(() => {
$('.grid').masonry({
// options
itemSelector: '.grid-item',
columnWidth: 200
});
});