首页 > 其他分享 >[echart] 字体自适应的方法(使用rem)

[echart] 字体自适应的方法(使用rem)

时间:2022-12-21 10:31:40浏览次数:41  
标签:echart res clientWidth fontSize rem 字体 document


function setFontSize(res){
const clientWidth = window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;
if (!clientWidth) return;
let fontSize = clientWidth / 1920;
return res*fontSize;
}

在需要设置字体的地方可以这样写,
如在1920屏宽下字体设置为12px,就可以传入12给fontSize

tooltip : {
trigger: 'axis',
textStyle:{
fontSize: setFontSize(12),
}
},

参考:
​echarts 字体自适应的方法(使用rem)​​


标签:echart,res,clientWidth,fontSize,rem,字体,document
From: https://blog.51cto.com/u_12881709/5957955

相关文章