Closed luzhaopan closed 3 years ago
yAxis: { type: 'value', axisLabel: { color: '#999', textStyle: { fontSize: 10 }, formatter: (value, index) => { return value + 'kg'; } }, }, formatter中的function不起作用
vue的data里不能放函数,会被序列化。只能手动setOptions 需要通过获取实例$curChart后。通过this.$curChart.setOption来设置echart配置
console.log(this.$refs['uni-ec-canvas'].$curChart.setOption())
vendor.js?t=wechat&s=1623979961505&v=67c7528469866a1a92210909eecde7b3:3982 [Vue warn]: Error in mounted hook: "TypeError: Cannot read property 'setOption' of undefined"
found in
--->
试了好多种,加了延迟也不行,setOption找不到,一直报的undefined
通过以下的方式可以了 mounted() { this.$refs['uni-ec-canvas'].ec.option = this.getOption() this.$refs['uni-ec-canvas'].init() },
yAxis: { type: 'value', axisLabel: { color: '#999', textStyle: { fontSize: 10 }, formatter: (value, index) => { return value + 'kg'; } }, }, formatter中的function不起作用