getComputedStyle()
该方法是window的方法,可以直接使用,主要用来获取元素当前的样式信息,可直接获取后转换成页面的rem,并在图表或其他地方使用。
例如:
const nowRem = getComputedStyle(document.documentElement).fontSize.replace('px', '') / 100
const option = {
series: [
{
axisLabel: {
show: true,
fontSize: 10 * nowRem
}
}
]
}
this.myChart = this.$echarts.init(this.$refs.myChart)
this.myChart.setOption(option)