如何在 VUE 组件上安装 masonry-layout
How install masonry-layout on VUE component
我刚刚通过 npm 安装了 masonry-layout,但我无法在我的组件中加载它。
import "masonry-layout";
export default {
name: "playerSkillComponent",
props: ['player'],
mounted: function () {
// initialization of masonry
var grid = document.querySelector('.masonry-grid');
var msnry = new Masonry( grid, {
// options...
columnWidth: '.masonry-grid-sizer',
itemSelector: '.masonry-grid-item',
percentPosition: true
});
}
}
这是我得到的错误:
[Vue warn]: Error in mounted hook: "ReferenceError: Masonry is not defined"
只更新第一行(有一个类型):
import Masonry from "masonry-layout";
我刚刚通过 npm 安装了 masonry-layout,但我无法在我的组件中加载它。
import "masonry-layout";
export default {
name: "playerSkillComponent",
props: ['player'],
mounted: function () {
// initialization of masonry
var grid = document.querySelector('.masonry-grid');
var msnry = new Masonry( grid, {
// options...
columnWidth: '.masonry-grid-sizer',
itemSelector: '.masonry-grid-item',
percentPosition: true
});
}
}
这是我得到的错误:
[Vue warn]: Error in mounted hook: "ReferenceError: Masonry is not defined"
只更新第一行(有一个类型):
import Masonry from "masonry-layout";