听说你的echarts图无法展示出来?
原因:methods中的方法是无法保证顺序的, 通常是因为你的数据没获取到 ,echarts就开始渲染了、这个时候是无法渲染出来的,并且不会报错。 如果想要正常渲染echarts,请找promise大哥、案例如下
一、多请求拼接的数据,请使用promise救场
Promise.all([
this.getUserCount(),
this.getFileCount(),
this.getParkingSpaceCount(),
this.getvehiclesInGarageCount(),
this.getviolationStatistics(),
this.getbillingStatistics()
]).then(() => {
this.initUserFileCountChart();
this.initParkingVehicleCountChart();
this.initViolationChart();
this.initBillingChart();
}).catch(error => {
console.error(error);
});
二、单一数据情况
只需要this.request.get(resp=>{ }).then( { 即可渲染})。