来自Web的图像不显示显示
我正在构建一个简单的网站,并尝试 src
slider中的任何图像(示例此图像),但根本不显示。
import { ArrowLeftOutlined, ArrowRightOutlined } from "@material-ui/icons";
import styled from "styled-components";
const Container = styled.div`
width: 100%;
height: 100vh;
display: flex;
background-color: coral;
position: relative;
`;
const Arrow = styled.div`
width: 50px;
height: 50px;
background-color: #fff7f7;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
position: absolute;
top: 0;
bottom: 0;
left: ${(props) => props.direction === "left" && "10px"};
right: ${(props) => props.direction === "right" && "10px"};
cursor: pointer;
margin: auto;
`;
const Wrapper = styled.div`
height: 100%;
`;
const Slide = styled.div`
display: flex;
align-items: center;
`;
const ImgContainer = styled.div`
flex; 1;
`;
const Image = styled.div``;
const InfoContainer = styled.div`
flex: 1;
`;
const Slider = () => {
return (
<div>
<Container>
<Arrow direction="left">
<ArrowLeftOutlined />
</Arrow>
<Wrapper>
<ImgContainer>
<Image src="https://images.unsplash.com/photo-1611690398208-18158228b6ba?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1171&q=80" />
</ImgContainer>
<InfoContainer></InfoContainer>
</Wrapper>
<Arrow direction="right">
<ArrowRightOutlined />
</Arrow>
</Container>
</div>
);
};
export default Slider;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它看起来像
image
只是一个样式的div:这将与写作相同(不起作用):
相反,请尝试更改
image
为样式img
:It looks like
Image
is just a styled div:This will be the same as writing (which doesn't work):
Instead, try changing
Image
to be astyled.img
:在JSX中,您应该使用
{}
进行属性值。例如&lt; image src = {img.jpg} /&gt; < /code>,
请进行此更改:
In JSX you should use
{}
for values of properties. For example<Image src={img.jpg} />
So do this change: