From 448db40b87d9fef5f4f33ba13d33479e2a2da836 Mon Sep 17 00:00:00 2001 From: hackrobot Date: Tue, 19 Mar 2024 21:21:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=95=E9=83=A8tabbar=E5=AD=90=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/componments/Tabbar/index.jsx | 0 src/componments/Tabbar/index.scss | 0 src/componments/TabbarCom/index.jsx | 35 ++++++++++++++++++++++++++++ src/componments/TabbarCom/index.scss | 11 +++++++++ src/pages/index/index.jsx | 7 ++++-- src/pages/my/index.jsx | 7 +++--- 6 files changed, 55 insertions(+), 5 deletions(-) delete mode 100644 src/componments/Tabbar/index.jsx delete mode 100644 src/componments/Tabbar/index.scss create mode 100644 src/componments/TabbarCom/index.jsx create mode 100644 src/componments/TabbarCom/index.scss diff --git a/src/componments/Tabbar/index.jsx b/src/componments/Tabbar/index.jsx deleted file mode 100644 index e69de29..0000000 diff --git a/src/componments/Tabbar/index.scss b/src/componments/Tabbar/index.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/componments/TabbarCom/index.jsx b/src/componments/TabbarCom/index.jsx new file mode 100644 index 0000000..9bda2e4 --- /dev/null +++ b/src/componments/TabbarCom/index.jsx @@ -0,0 +1,35 @@ +import { View } from "@tarojs/components"; +import { AtAvatar, AtTag, AtIcon, AtTabBar, AtButton } from "taro-ui"; +import Taro from "@tarojs/taro"; +import react from "react"; + +const TabbarCom = (props) => { + const [active, setActive] = react.useState(props?.active ?? 0); + + return ( + + { + setActive(current) + if (current === 0) { + Taro.redirectTo({ + url: "/pages/index/index", + }); + }else{ + Taro.redirectTo({ + url: "/pages/my/index", + }); + } + }} + current={active} + /> + + ); +}; + +export default TabbarCom; diff --git a/src/componments/TabbarCom/index.scss b/src/componments/TabbarCom/index.scss new file mode 100644 index 0000000..3cbcefd --- /dev/null +++ b/src/componments/TabbarCom/index.scss @@ -0,0 +1,11 @@ +.tabbbarDiv { + width: 100%; + height: 140px; + // background-color: red; + } + + .tabbbar { + position: fixed; + bottom: 0px; + width: 100%; + } \ No newline at end of file diff --git a/src/pages/index/index.jsx b/src/pages/index/index.jsx index 89ddfd2..e2a8d47 100644 --- a/src/pages/index/index.jsx +++ b/src/pages/index/index.jsx @@ -8,6 +8,7 @@ import guangzhou from "@/images/city/guangzhou.jpg"; import shanghai from "@/images/city/shanghai.jpg"; import shenzhen from "@/images/city/shenzhen.jpg"; import touxiang from "@/images/index/touxiang.jpg"; +import TabbarCom from "@/componments/TabbarCom"; import { useEffect, useState } from "react"; // import beijing from "../../images/city/beijing.jpg"; @@ -181,7 +182,7 @@ export default function Index() { {/* 底部tabbar */} - + {/* - + */} + + ); } diff --git a/src/pages/my/index.jsx b/src/pages/my/index.jsx index e1e8b26..d5167ca 100644 --- a/src/pages/my/index.jsx +++ b/src/pages/my/index.jsx @@ -17,7 +17,7 @@ import guangzhou from "@/images/city/guangzhou.jpg"; import shanghai from "@/images/city/shanghai.jpg"; import shenzhen from "@/images/city/shenzhen.jpg"; import touxiang from "@/images/index/touxiang.jpg"; - +import TabbarCom from "@/componments/TabbarCom"; import { useEffect, useState } from "react"; const my = () => { const [open, setopen] = useState(false); @@ -69,7 +69,7 @@ const my = () => { {/* 底部tabbar */} - + {/* { }} current={1} /> - + */} + ); };