TypeError: Failed to set an indexed property on 'CSSStyleDeclaration': Indexed p

2,741 阅读1分钟
  • 基于react项目:

  • 报错: TypeError: Failed to set an indexed property on 'CSSStyleDeclaration': Indexed property setter is not supported.

如下图:

Snipaste_2021-08-05_13-42-43.png

  • 了解:
CSS 样式声明对象(CSSStyleDeclaration)
CSSStyleDeclaration 对象
CSSStyleDeclaration 对象表示一个 CSS 属性-值(property-value)对的集合。
  • 原因:样式问题 style= 与 className= 是否赋值及格式写错写反

我在项目中出现此问题,原因是:组件中有个style且可自定义,后端返回待渲染数据时里面的有个字段名叫style并有值(style=1),故造成渲染时样式不对而报错。

要细心哦!!!

参考文章:

https://blog.csdn.net/CCQStudy/article/details/109300566
https://www.cnblogs.com/jichi/p/11896544.html