在使用react的innerHtml时,如果碰到这个问题,是因为在这个元素下不能有任何东西,注释,空格都不行,所以直接把那个div中的空格删掉就行
这串代码的
dangerouslySetInnerHTML={{ __html: subItem.content as string }}
中的
_html的值为string 所以我加上了as string ts中断言为string就行
问题解决方案来源:解决方案来源
在使用react的innerHtml时,如果碰到这个问题,是因为在这个元素下不能有任何东西,注释,空格都不行,所以直接把那个div中的空格删掉就行
这串代码的
dangerouslySetInnerHTML={{ __html: subItem.content as string }}
中的
_html的值为string 所以我加上了as string ts中断言为string就行
问题解决方案来源:解决方案来源