简体   繁体   English

显示图像使页面空白 React JS

[英]Display image makes page blank React JS

When I add this line off code, instead of showing the image, my page gets blank.当我在代码中添加这一行时,我的页面没有显示图像,而是空白。 How can I fix this?我怎样才能解决这个问题?

<img>
   src={"https://media1.s-nbcnews.com/i/newscms/2019_21/2870431/190524-classic-american-cheeseburger-ew-207p_d9270c5c545b30ea094084c7f2342eb4.jpg"}  alt={''}
</img>

You are using the img tag incorrectly, Please update it as:您使用的 img 标签不正确,请将其更新为:

<img src={'https://media1.s-nbcnews.com/i/newscms/2019_21/2870431/190524-classic-american-cheeseburger-ew-207p_d9270c5c545b30ea094084c7f2342eb4.jpg'} />

Also, recheck the image link as it shows unavailable.此外,请重新检查图像链接,因为它显示不可用。

src is not the child component of tag. src 不是标签的子组件。 src is a attribute of tag. src 是标签的一个属性。

<img src={"https://media1.s-nbcnews.com/i/newscms/2019_21/2870431/190524-classic-american-cheeseburger-ew-207p_d9270c5c545b30ea094084c7f2342eb4.jpg"}  alt={''}

/> />

check https://www.w3schools.com/tags/tag_img.asp for details.查看https://www.w3schools.com/tags/tag_img.asp了解详情。

img is self closing tag and it's required the src attribute. img 是自闭合标签,它需要 src 属性。 correct way to use img tag is:使用 img 标签的正确方法是:

<img src={"https://media1.s-nbcnews.com/i/newscms/2019_21/2870431/190524-classic-american-cheeseburger-ew-207p_d9270c5c545b30ea094084c7f2342eb4.jpg"} />

check https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img for more information检查https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img了解更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM