源码之家

  • 首页
  • 文章
  • 问答
  • 下载
您的位置: 首页  >  文章  >  解决Typescript报错:Property 'style' does not exist on type 'Element'

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

分类: 文章 • 2023-01-22 00:00:52

直接说问题吧:

说一下我的最初代码:

解决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

相关推荐

  • vscode中的vue项目报错Property ‘xxx‘ does not exist on type ‘CombinedVueInstance<{ readyOnly...Vetur(2339
  • vue3 中使用 element-ui 时出现的 Property ‘$notify‘ does not exist on type ‘App‘.
  • vscode中的vue项目报错Property ‘xxx‘ does not exist on type ‘CombinedVueInstance<{ readyOnly...Vetur(2339)
  • Typescript error :Property mozRequestFullScreen' does not exist on type 'HTMLElement'
  • Typescript error :Property 'xxx' does not exist on type 'yyy'.
  • 解决Typescript报错:Property 'style' does not exist on type 'Element'
  • Ts Js input赋值报错The property 'value' does not exist on value of type 'HTMLElement'解决办法
  • VMware安装XenServer报错解决办法
  • npm install安装过程报错解决办法
    网站免责声明 网站地图 最新文章 用户隐私 版权申明
本站所有数据收集于网络,如果侵犯到您的权益,请联系网站进行下架处理。   

Copyright © 2018-2021   Powered By 源码之家    备案号:   粤ICP备20058927号