tooltip: {
formatter: (params) => {
// 使用 map 函数遍历数据构建 HTML 字符串
let html = mapIndexList.map(item => {
return `
<div>
<span>${item.label}</span>
<div>
<span class="num">${(item.value != undefined && item.value != null) ? item.value : '--'}</span>
<span class="unit" style="display: ${(item.value != undefined && item.value != null) ? 'inline' : 'none'}">${item.unit}</span>
</div>
</div>
`
}).join(''); // .join('')去除map返回结果中的逗号
return html;
},
}
react echarts遍历数据生成tooltip模板字符串拼接html出现逗号
最新推荐文章于 2024-08-27 16:49:00 发布