首页 > 解决方案 > 如何访问“build.after”中的组件大小 [Glide.js v 3.1.0]

问题描述

不知道我应该如何使用组件。我没有使用模块化构建。

import Glide from '@glidejs/glide'

var glide = new Glide('.glide')

glide.on('build.after', function() {
  // How do I access the component Sizes and the property slideWidth here?
})

glide.mount()

标签: glidejs

解决方案


您无权访问事件回调中的组件集合。您必须改为创建自定义组件。文档中的更多信息。

var Example = function (Glide, Components, Events) {
  return {
    mount () {
      // Here you can access `Sizes` module
      console.log(Components.Sizes)
    }
  }
}

new Glide('.glide').mount({
  'Example': Example
})

推荐阅读