antvis/G2

The issue has been closed
g2官网 API 教程 -> 快速上手 demo 中的 new Chart()报 Chart is not defined 错 #3566
MuGuiLin posted onGitHub
- I have searched the issues of this repository and believe that this is not a duplicate.
Reproduction link
https://g2.antv.vision/zh/docs/manual/getting-started
Steps to reproduce
【问题】: 1、在html文件中 引入在线资源 <script src="https://gw.alipayobjects.com/os/lib/antv/g2/4.1.23/dist/g2.min.js"></script> 或 下载后在本地引入g2.min.js脚本。
2、在js中实例化 new Chart()时报 Chart is not defined 错误。
const chart = new Chart({ **// Chart is not defined**
container: 'c1',
width: 600,
height: 300,
});
【原因】: 由于g2升级后,实例化应该用:new G2.Chart() 才对。
【解决】: 请更新一下g2官网 API 教程,将 new Chart() 改为 new G2.Chart() ,以免在新手初次使用时,按照官网API教程遇到这个问题。
const chart = new G2.Chart({
container: 'c1',
width: 600,
height: 300,
});
Environment | Info |
---|---|
g2 | 4.1.23 |
System | windows 10 |
Browser | Google Chrome 92.x (64) |
<!-- generated by antv-issue-helper. DO NOT REMOVE -->