报错场景:
将echarts.setOption({
backgroundColor: "#02AFDB",
tooltip: {},
...等内容
})
提取封装到js文件中会报一下错:
1.vue.esm.js?efeb:628 [Vue warn]: Error in mounted hook: "TypeError: Cannot read property 'get' of undefined"
2.Uncaught Error: `resize` should not be called during main process.
报错代码
解决方式1:
1.未解决
2.Uncaught Error: `resize` should not be called during main process
设置延迟
setTimeout(myEcharts.setOption(chinaMapOption1), 500);
解决方式2:
原因:抽取出来的js对外暴漏的是函数,使用错了
更改后代码
myEcharts.setOption(chinaMapOption);
改为
myEcharts.setOption(chinaMapOption());