vue3中使用echarts遇到的两个问题
1、切换路由后再切回来,图标显示空白

let dom = document.getElementById('charDom')
// 解决方法
dom.removeAttribute('_echarts_instance_')

2、resize报错
报错信息如下

barPolar.js:63 Uncaught TypeError: Cannot read property 'type' of undefined
    at barPolar.js:63
    at GlobalModel2.<anonymous> (Global.js:682)
    at Array.forEach (<anonymous&gt;)
    at each (util.js:205)
    at GlobalModel2.eachSeriesByType (Global.js:678)
    at Object.barLayoutPolar (barPolar.js:61)
    at Object.overallReset (util.js:310)
    at Task2.overallTaskReset [as _reset] (Scheduler.js:460)
    at Task2._doReset (task.js:202)
    at Task2.perform (task.js:117)

原因是因为存储echarts对象变量使用reactive响应定义使用常量定义就好了

// 错误定义
const charObj = reactive({
	barChart: undefined
})
// 正确定义
const charObj = {
	barChart: undefined
}

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注