index.tsx 739 B

12345678910111213141516171819202122232425262728293031
  1. import { Tabbar } from "@nutui/nutui-react-taro";
  2. import { useEffect, useState } from "react";
  3. import { navigateTo } from "@tarojs/taro";
  4. const TabbarCom = () => {
  5. const [activeIndex, setActiveIndex] = useState(0);
  6. useEffect(() => {
  7. setActiveIndex(0);
  8. }, []);
  9. return (
  10. <Tabbar
  11. fixed
  12. safeArea
  13. value={activeIndex}
  14. onSwitch={(value) => {
  15. console.log(value);
  16. setActiveIndex(value);
  17. if (value === 2) {
  18. navigateTo({ url: "/pages/publish/index" });
  19. }
  20. }}
  21. >
  22. <Tabbar.Item title="首页" />
  23. <Tabbar.Item title="消息" />
  24. <Tabbar.Item title="发布" />
  25. <Tabbar.Item title="我的" />
  26. </Tabbar>
  27. );
  28. };
  29. export default TabbarCom;