echarts中使用rem,px转换为rem字体自适应

// 先写个方法
function fontSize(res){
	let docEl = document.documentElement,
		clientWidth = window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;
	if (!clientWidth) return;
	let fontSize = 100 * (clientWidth / 1920);
	return res*fontSize;
}

使用时
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/anny_mei/article/details/120325543