【问题标题】:How install masonry-layout on VUE component如何在 VUE 组件上安装 masonry-layout
【发布时间】:2019-11-12 08:59:18
【问题描述】:

我刚刚通过 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 警告]:挂载钩子错误:“ReferenceError: Masonry is not defined”

【问题讨论】:

    标签: vue.js npm masonry


    【解决方案1】:

    只更新第一行(有一个类型):

    import Masonry from "masonry-layout";
    

    【讨论】:

      猜你喜欢
      • 2021-07-25
      • 2021-12-31
      • 1970-01-01
      • 2020-01-20
      • 2019-11-02
      • 2019-05-16
      • 1970-01-01
      • 2021-06-11
      • 2018-11-16
      相关资源
      最近更新 更多