feat: 修复组件刷新错误

This commit is contained in:
huanghao1412 2024-01-24 10:26:37 +08:00
parent ee54a366f0
commit c60b2c2b8f
2 changed files with 5 additions and 3 deletions

View File

@ -40,7 +40,6 @@ export const useChartCommonData = (
if(targetComponent.option){
let seriesItem = cloneDeep(targetComponent.option.series[0])
let series = []
targetComponent.option.series.splice(0)
if(dataset.dimensions.length - 1) {
for(let i = 0; i < dataset.dimensions.length - 1; i++) {
series.push(cloneDeep(seriesItem))
@ -50,7 +49,7 @@ export const useChartCommonData = (
series = [seriesItem]
}
if (vChartRef.value) {
setOption(vChartRef.value, { series, dataset })
setOption(vChartRef.value, { series, dataset: dataset })
}
}
}
@ -92,6 +91,7 @@ export const useChartCommonData = (
if (res && res.errcode === ResultErrcode.SUCCESS) {
try {
const { data } = res
console.log(data)
if(Object.prototype.toString.call(data) === '[object Array]') {
if(data.length) echartsUpdateHandle(data[0])
}

View File

@ -44,5 +44,7 @@ export const setOption = <T extends typeof VChart | undefined, D>(instance: T, d
if (!instance) return
const option = instance.getOption()
option.dataset = null
instance.setOption(data)
instance.setOption(data, {
replaceMerge: ['series'],
})
}