gpt4 book ai didi

javascript - React 渲染 标签

转载 作者:行者123 更新时间:2023-12-02 21:48:12 26 4
gpt4 key购买 nike

对于以下 react 代码:

ReactDOM.render(<div className="divcss5">
<img src={'/auto_merge_deployment.png'}
alt="Auto Merge Deployment"
align="bottom"
id="auto_merge_deployment"
style={style}>Auto Merge Deployment</img>
<br></br>
<p><i className="fa fa-spinner fa-spin fa-3x fa-fw"
style={{fontSize: "1.73em"}}
></i>Icon</p>
</div>, document.getElementById("icon_tip_div"));

我得到:

Error: img is a void element tag and must neither have children nor use dangerouslySetInnerHTML. in img in div

是否是因为src格式不正确或者路径错误,导致找不到图片?

最佳答案

唯一出错的是<img>标签不应有结束标签,需要先将其删除。阅读 documentation :

The HTML <img> element embeds an image into the document.

也在 w3schools :

In HTML the <img> tag has no end tag.

我将删除结束标记,如下所示:

<img src={'/auto_merge_deployment.png'}
alt="Auto Merge Deployment"
align="bottom"
id="auto_merge_deployment"
style={style}>Auto Merge Deployment

希望对您有所帮助!

关于javascript - React 渲染 <img> 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60197402/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com