使用此事件获取html元素的宽度

时间:2021-01-20 19:38:53

This meteor client code needs the width of the element for which the event happened but failed to get it. How can it be done? Thanks

此流星客户端代码需要事件发生但未能获取的元素的宽度。怎么做到呢?谢谢

Template.swipe.events({
  'mouseup .swipe': function(e) {
    utility.mouseUp(e);
  }
});

utility = (function () {

  return {
    mouseUp: (event) => {
      console.log(event.currentTarget.width);
    }
}());

1 个解决方案

#1


0  

Use the event.currentTarget.offsetWidth property instead of width.

使用event.currentTarget.offsetWidth属性而不是width。

#1


0  

Use the event.currentTarget.offsetWidth property instead of width.

使用event.currentTarget.offsetWidth属性而不是width。