直接说问题吧:

说一下我的最初代码:

解决Typescript报错:Property 'style' does not exist on type 'Element'

此时使用style修改节点的样式时报错了,报错信息如下:

解决Typescript报错:Property 'style' does not exist on type 'Element'

直接提示我们'style' does not exist 百度查找之后发现是我们没有给list做类型断言,所以typescript在检查类型的时候直接报错了。

解决方法如下:
给list添加<HTMLElement>做类型断言,完美解决

解决Typescript报错:Property 'style' does not exist on type 'Element'

参考资料:https://www.cnblogs.com/PearlRan/p/10155754.html

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-18
  • 2021-09-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2021-08-11
  • 2021-09-08
相关资源
相似解决方案