问题描述
uni-app使用echarts图表,接口请求数据更新后,图表不刷新。
解决方案
更新option前先调用clear()
- clear():清空当前实例,会移除实例中所有的组件和图表。
initChart() {
this.gaugeChart = echarts.init(document.getElementById('chart'))
this.updateGaugeChart()
},
updateGaugeChart(num = 0) {
let option = {...}
this.gaugeChart.clear()
this.gaugeChart.setOption(option)
},
文章讲述了在uni-app项目中使用echarts时,如何在接口请求数据更新后使图表刷新的问题。提出了解决方案:在更新option之前调用clear()方法清空图表实例并重新设置option。
3万+

被折叠的 条评论
为什么被折叠?



