[Echarts使用]:bug记录

问题1: z / z2 / zlevel of displayable is invalid, which may cause unexpected errors

// 在series 选项中设置zlevel、z 属性即可解决
let option: echarts.EChartsCoreOption = {
		...,
		series: {
			name: data.name,
			type: "line",
			smooth: true,
			showSymbol: false,
			data: data.list,
			zlevel: 1,
            z: 1
		}
	};

问题2:There is a chart instance already initialized on the dom.

// 初始化echarts实例时检查是否已经存在 即可解决


问题3:Unable to preventDefault inside passive event listener invocation.

[Echarts使用]:bug记录_第1张图片

// 通过劫持addEventListener事件,将passive改成true就可以解决Unable to preventDefault inside passive event listener invocation报错
(function () {
	if (typeof EventTarget !== "undefined") {
		let originalFunc = EventTarget.prototype.addEventListener; // 先存储原来的事件
		EventTarget.prototype.addEventListener = function (type, fn, capture) {
			if (typeof capture !== "boolean") {
				capture = capture || {};
				capture.passive = false; // 这句是关键的
			}
			originalFunc.call(this, type, fn, capture);
		};
	}
})();

你可能感兴趣的:(echarts,bug,前端)