我数据是在mounted里请求的数据格式什么的都对的,也请求过来了,但是图表显示不出来,我把数据写死在data里就能显示,请问这是什么问题,是生命周期不对的问题吗,下面是我的代码,我把echarts把配置去掉了太长了,感谢
<template>
<div>
<div class="wrap">
<div id="chart_bar"></div>
</div>
</div>
</template>
<script>
import { getFaultList } from "@/api/exh/exh_3";
import echarts from "echarts";
export default {
data() {
return {
fullHeight: document.documentElement.clientHeight,
xAxisData: [],//x轴数据
seriesData: [],//y轴数据
};
},
created() {
},
mounted() {
this.getFault("YEAR");
},
methods: {
getFault(dateType = "YEAR") {
getFaultList({ type: dateType }).then(res => {
for (let index = 0; index < 9; index++) {
this.seriesData.push(res.data.data[index].count);
this.xAxisData.push(res.data.data[index].deviceName);
}
});
},
changeFixed(clientHeight) {}
},
};
</script>
在重新获取数据后,在调用一次echarts的setOption方法