猿问

vue中使用echarts通过ajax获取数据动态赋值

这个option在mounted里

https://img1.mukewang.com/5b47706e0001d68108000653.jpg当我点击按钮在methods里获取数据,怎样给legend和series里的data赋值呢?难道只能把option的代码放进ajax请求里吗?


宝慕林4294392
浏览 11543回答 2
2回答

森栏

我司做法是把常用的几个Echart图表的option配置写几个函数封装好,用的时候直接传数据进去就行

小怪兽爱吃肉

在data中声明 option配置在Axios中修改Axios.then((res)=>{         this.option.serise[0] = res.data.data;         //数据处理之后       init echarts函数 })
随时随地看视频慕课网APP
我要回答