echarts 5.0之map使用,echarts报错‘regions‘undefined:
原因是:echarts版本太高了不支持map中国地图
解决方法:
方法一:降低echarts版本(4.9及以下)
方法二:在局部引入4.9及以下的js版本
-
定义一个变量接收文件路径userFunctionJS: any="…/…/assets/js/echarts.min.js";
-
添加方法
ngAfterViewInit(){
if (this.userFunctionJS){
this.loadScript(this.userFunctionJS);
}else{
console.log("userFunctionJS=" + this.userFunctionJS);
}
}
loadScript(scriptUrl: string) {
return new Promise((resolve, reject) => {
console.log("loadScript:" + scriptUrl);
const scriptElement = document.createElement('script')
scriptElement.src = scriptUrl
scriptElement.onload = resolve
document.body.appendChild(scriptElement)
})
}
其他方法https://blog.csdn.net/weixin_43622131/article/details/114684724