【发布时间】:2021-10-29 06:47:25
【问题描述】:
我创建了一个弯曲的容器,我尝试在我的项目中使用它,但是报错,我不知道如何解决,有没有人有什么想法?
import Image from "next/image";
import curveImage from "/public/curve.png";
import curveReverseImage from "/public/curve-reverse.png";
import curveImageBlack from "/public/curve-black.png";
import curveReverseImageBlack from "/public/curve-reverse-black.png";
type Props = {
children: JSX.Element;
curveTop?: "white" | "black" | "none";
curveBottom?: "white" | "black" | "none";
[defaultParam: string]: any;
};
export default function CurvedContainer({
children,
curveTop = "white",
curveBottom = "white",
...rest
}: Props) {
return (
<div {...rest} className={`${rest.className} flex flex-col`}>
{curveTop != "none" && (
<div className="curveTop" style={{ marginTop: -1 }}>
<Image
height="250"
alt="top image"
src={
curveTop == "white" ? curveReverseImage : curveReverseImageBlack
}
/>
</div>
)}
{children}
{curveBottom != "none" && (
<div className="curveTop -mb-2">
<Image
height="250"
alt="top image"
src={curveBottom == "white" ? curveImage : curveImageBlack}
/>
</div>
)}
</div>
);
}
我不知道为什么会不幸出现此错误。如果有人可以帮助我,那就太棒了!
<Container
className="none"
curveTop="white"
curveBottom="none"
>
<div className="flex flex-row items-center justify-center p-8">
<a href="#" className={`bg-black text-white font-bold
tracking-wider text-sm text-center uppercase rounded-full px-8 py-2 shadow-lg `}
type="button">
Saiba Mais
</a>
</div>
</Container>
这里有错误:
【问题讨论】:
标签: reactjs typescript react-props children