This commit is contained in:
hackrobot
2024-09-24 07:46:53 +08:00
parent 518eea50c3
commit 3e54c3efab
2 changed files with 35 additions and 22 deletions

View File

@@ -28,38 +28,41 @@ import beijing from "../../images/beijing.jpg";
import shanghai from "../../images/shanghai.jpg"; import shanghai from "../../images/shanghai.jpg";
import shenzhen from "../../images/shenzhen.jpg"; import shenzhen from "../../images/shenzhen.jpg";
// export default class Index extends Component { // export default class Index extends Component {
const Index = () => { const Index = () => {
const [current, setcurrent] = useState(0); const [current, setcurrent] = useState(0);
const custDom = () => {
return <View className="custDom">custDom</View>;
};
return ( return (
<View className="Index"> <View className="Index">
<View className="up"></View> <View className="up"></View>
<View className="items"> <View className="items">
{/* 数组尽量是4的倍数 */} {/* 数组尽量是4的倍数 */}
{[ {[
{ img: beijing, b: 2 }, { img: beijing, type: "item", dom: "" },
{ img: shanghai, b: 2 }, { img: shanghai, type: "item", dom: "" },
{ img: shenzhen, b: 2 }, { img: shenzhen, type: "custom", dom: custDom() },
// { img: shanghai, b: 2 }, { img: shenzhen, type: "item", dom: "" },
// { img: shanghai, b: 2 },
// { img: shanghai, b: 2 },
// { img: shanghai, b: 2 },
// { img: shanghai, b: 2 },
].map((item, index) => { ].map((item, index) => {
return ( if (item.type === "custom") {
<View className="item"> return <View className="item"> {item.dom}</View>;
<View className="itemUp"> itemUp</View> } else {
<View className="itemiddle"> itemiddle</View> return (
<View className="itemDown">itemDown </View> <View className="item">
<Image <View className="itemUp"> itemUp</View>
style="width: 100%;height: 100%;background: #fff;border-radius: 5%;z-index:-99" <View className="itemiddle"> itemiddle</View>
// mode="heightFix" <View className="itemDown">itemDown </View>
src={item.img} <Image
/> style="width: 100%;height: 100%;background: #fff;border-radius: 5%;z-index:0"
</View> // mode="heightFix"
); src={item.img}
/>
</View>
);
}
})} })}
</View> </View>
{/* <View className="right">22</View> */} {/* <View className="right">22</View> */}

View File

@@ -26,12 +26,13 @@
max-width: 350px; /* 设置最大宽度 */ max-width: 350px; /* 设置最大宽度 */
// width: 100%; /* 确保可以响应式变化 */ // width: 100%; /* 确保可以响应式变化 */
height: 280px; height: 280px;
// background-color: yellow; background-color: yellow;
margin-bottom: 20px; margin-bottom: 20px;
border-radius: 5%; border-radius: 5%;
position: relative; position: relative;
color: white; color: white;
.itemUp { .itemUp {
z-index: 1;
width: 100%; width: 100%;
height: 20px; height: 20px;
background-color: burlywood; background-color: burlywood;
@@ -39,6 +40,7 @@
top: 0px; top: 0px;
} }
.itemiddle { .itemiddle {
z-index: 1;
width: 100%; width: 100%;
height: 20px; height: 20px;
// background-color: green; // background-color: green;
@@ -46,6 +48,7 @@
top: 50%; top: 50%;
} }
.itemDown { .itemDown {
z-index: 1;
width: 100%; width: 100%;
height: 20px; height: 20px;
// background-color: red; // background-color: red;
@@ -54,4 +57,11 @@
} }
} }
} }
.custDom {
width: 100%;
height: 40px;
background-color: red;
color: aqua;
}
} }