美文网首页
typeScript中遇到的鸟问题及解决

typeScript中遇到的鸟问题及解决

作者: 春木橙云 | 来源:发表于2019-08-27 11:16 被阅读0次

最近在使用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!

相关文章

网友评论

      本文标题:typeScript中遇到的鸟问题及解决

      本文链接:https://www.haomeiwen.com/subject/sawsectx.html