首页 > 解决方案 > 任何人都可以解释语法

问题描述

  const lastTick = this.xAxis[0].ticks[this.xAxis[0].tickPositions.length - 1];
  const { width } = lastTick.label.getBBox();
  const { chartWidth } = this;
  lastTick.label.attr({ x: chartWidth - (0.7) * width });

这是highcharts代码。我想要{ width },的意思{ chartWidth }

标签: javascript

解决方案


这称为解构赋值。它类似于写作

const chartWidth = this.chartWidth;
const width = lastTick.label.getBBox().width;

推荐阅读