最近在使用angular+typescript做项目,遇到这个鸟问题,解决它任务减轻大半,开心哈哈哈哈!
- 报错:
类型“HTMLElement”的参数不能赋给类型“HTMLDivElement | HTMLCanvasElement”的参数。
Type 'HTMLElement' is missing the following properties from type 'HTMLCanvasElement': height, width, getContext, toBlob, and 2 more.ts(2345)
- 源代码:
const myChart:any = echarts.init(document.getElementById('main'));
- 解决措施:
const mainElement = <HTMLCanvasElement>document.getElementById('main');
const myChart: any = echarts.init(mainElement)
lalala the end!
网友评论