//基于准备好的dom,初始化echarts实例
const barDOM: any = ref();
var myChart: any;
let echartNull: any = null;
// 渲染echart
const init_chart = () => {
if (myChart != null && myChart != "" && myChart != undefined) {
myChart .dispose(); //销毁
}
myChart = echarts.init(barDOM.value, echartNull, { locale: "ZH" });
var option;
if (xAxis.length == 0) {//判断x轴的数据是否为空
//空数据
option = {
title: {
text: "暂无数据",
x: "center",
y: "center",
textStyle: {
fontSize: 16,
color: "#ffffff",
fontWeight: "normal",
},
},
};
}else {
option = {}
}
myChart.setOption(option);
window.onresize = function () {
myChart.resize();
};
}
标签:暂无,option,myChart,vue3,数据,any,echart
From: https://www.cnblogs.com/JaneLifeBlog/p/17869236.html