uniapp中使用echarts,在tooltip中设置formatter页面渲染成字符串了
这是formatter内容:
// 工具浮窗
tooltip: {
trigger: "axis",
// 鼠标移入的轴线配置
axisPointer: {
lineStyle: {
color: "#FF8B02"
}
},
formatter: (e) => this.getCurrentDate(e)
}
getCurrentDate(params) {
let res = ""
let time = `<span>${params[0].axisValue}</span><br/>`
res += time
for (let i = 0; i < params.length; i++) {
res += `<span style="display:inline-block;margin-right:4px;">${params[i].marker}</span>
<span style="display:inline-block;width:80px;height:20px;">${params[i].seriesName}</span>
<span style="display:inline-block;width:30px;height:20px;">${params[i].data}</span><br/>`
}
return res
}
奇怪的是中间那个圆点解析成功了,圆点的数据如下:
因为echarts 源码中的判断 typeof wx 其中的 wx 变量与uniapp 中重复了 修改下源码就可以了