From 6ffbfe6805b9ddca2d9e076b08a3bf1676e142c4 Mon Sep 17 00:00:00 2001 From: HuaYu <15600557119@163.com> Date: Thu, 12 Jan 2023 21:47:39 +0800 Subject: [PATCH] ant-Buttom --- src/App.js | 37 ++++++++++---------- src/pages/Buttom/index.css | 25 ++++++++++++++ src/pages/Buttom/index.js | 69 ++++++++++++++++++++++++++++++++++++++ src/pages/Home/index.js | 10 ------ 4 files changed, 113 insertions(+), 28 deletions(-) create mode 100644 src/pages/Buttom/index.css create mode 100644 src/pages/Buttom/index.js delete mode 100644 src/pages/Home/index.js diff --git a/src/App.js b/src/App.js index 5ec1899..9ae0a1b 100644 --- a/src/App.js +++ b/src/App.js @@ -1,24 +1,25 @@ -import './App.css'; -import {Button} from 'antd-mobile' -import { BrowserRouter as Router,Route,Link, Routes } from 'react-router-dom'; -import Home from './pages/Home' -import CityList from './pages/CityList'; -import News from './pages/News'; -import './index.css'; +import { BrowserRouter as Router, Route, Link, Routes } from 'react-router-dom'; +import { Home, Todo, Message, PersonalCenter, Bottom } from './pages/Buttom/index' +import './pages/Buttom/index.css' +import { NavBar, TabBar } from 'antd-mobile' function App() { return ( -
- - - }> - }/> - - }/> - +
+
+ 配合路由使用 +
+
+ + }> + }> + }> + }> + +
+
+ +
); diff --git a/src/pages/Buttom/index.css b/src/pages/Buttom/index.css new file mode 100644 index 0000000..b4aa589 --- /dev/null +++ b/src/pages/Buttom/index.css @@ -0,0 +1,25 @@ +.app { + height: 100vh; + display: flex; + flex-direction: column; +} + +.top { + flex: 0; + border-bottom: solid 1px var(--adm-color-border); +} + +.body { + flex: 1; + display: flex; + justify-content: center; + align-items: center; +} + +.adm-tab-bar { + flex: 0; + border-top: solid 1px var(--adm-color-border); + width:100%; + position: fixed; + bottom:0; +} \ No newline at end of file diff --git a/src/pages/Buttom/index.js b/src/pages/Buttom/index.js new file mode 100644 index 0000000..665b2c5 --- /dev/null +++ b/src/pages/Buttom/index.js @@ -0,0 +1,69 @@ +import React ,{FC} from "react"; +import { NavBar, TabBar } from 'antd-mobile' +import { + Route,Routes, + useLocation, + MemoryRouter as Router, + useNavigate, +} from 'react-router-dom' +import { + AppOutline, + MessageOutline, + UnorderedListOutline, + UserOutline, +} from 'antd-mobile-icons' +export function Bottom (){ + const navigate = useNavigate(); + const location = useLocation() + const { pathname } = location + + const setRouteActive = (value) => { + navigate(value) + } + + const tabs = [ + { + key: '/home', + title: '首页', + icon: , + }, + { + key: '/todo', + title: '待办', + icon: , + }, + { + key: '/message', + title: '消息', + icon: , + }, + { + key: '/me', + title: '我的', + icon: , + }, + ] + + return ( + setRouteActive(value)}> + {tabs.map(item => ( + + ))} + + ) + } + export function Home() { + return
首页
+ } + + export function Todo() { + return
待办
+ } + + export function Message() { + return
消息
+ } + + export function PersonalCenter() { + return
我的
+ } \ No newline at end of file diff --git a/src/pages/Home/index.js b/src/pages/Home/index.js deleted file mode 100644 index f8874d1..0000000 --- a/src/pages/Home/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import React from "react"; -import { Routes,Route } from "react-router-dom"; -import News from "../News"; -export default class Home extends React.Component{ - render(){ - return (
首页 - }/> -
) - } -} \ No newline at end of file