我正在关注ReactJS 的本指南,并在使用指南指定的 Img 标记时遇到了上述错误。
<Img src={keepLogo} alt="Google keep logo" />
导致此错误:
Warning: Invalid value for prop `src` on <img> tag. Either remove it from the element, or pass a string or number value to keep it in the DOM.
我如何能够将源链接到反应图标?以及为什么源不起作用。
这是我的代码:
import React from 'react'
import styled from 'styled-components';
import { DiFirebase, DiGoogleDrive, DiReact } from 'react-icons/di';
const Nav = styled.nav`
display: flex;
justify-content: space-between;
align-items: center;
padding: 4px 25px;
border-bottom: 1px solid rgba(60, 64, 67, 0.2);
`;
const ImgWrap = styled.div`
display: flex;
align-items: center;
`;
const Img = styled.img`
width: 40px;
height: 40px;
`
const Header = () => {
return (
<Nav>
<h1>Keep clone</h1>
<ImgWrap>
<Img src={DiGoogleDrive} alt="Google keep logo" />
<p>+</p>
<Img src={DiReact} alt="React logo"/>
<p>+</p>
<Img src={DiFirebase} alt="firebase logo"/>
</ImgWrap>
</Nav>
)
}
export default Header