我正在尝试在我的React组件中显示图像。以下是我的代码:
import React from 'react';
const Header = () => {
const posterIMG = "https://cdn-images-1.medium.com/max/800/1*AfzFa8zO_dQOmuSHL7bEww.png";
return(
<div className="top_nav">
<div className="nav_menu">
<nav>
<ul className="nav navbar-nav navbar-right">
<li className="">
<a href="javascript:void(0);" className="user-profile dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<img id="postertest" src={"/public/images/img.jpg"} className="img" alt="Profile Image"/>
<span className=" fa fa-angle-down"/>
</a>
</li>
</ul>
</nav>
</div>
<div className="poster-container nopadding col-xs-12 col-md-4 pull-md-8 col-lg-5 pull-lg-7 ">
<img id="postertest" className='poster' src={posterIMG}/>
</div>
</div>
);
};
export default Header;
代码显示图像,但同时抛出控制台错误。当我删除图像标记时,控制台中没有错误。
有人可以帮我解决这里发生的事情吗?