通过此事件获取 html 元素的宽度

Fre*_* J. 4 javascript jquery meteor

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

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

utility = (function () {

  return {
    mouseUp: (event) => {
      console.log(event.currentTarget.width);
    }
}());
Run Code Online (Sandbox Code Playgroud)

小智 5

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