From 49d6146e3fa9aa4029664df86a9a9589298145e8 Mon Sep 17 00:00:00 2001 From: HuaYu <15600557119@163.com> Date: Sat, 14 Jan 2023 15:43:31 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AB=98=E9=98=B6=E7=BB=84=E4=BB=B6=E5=8C=85?= =?UTF-8?q?=E8=A3=B9=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 2 +- src/pages/Home/index.js | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/App.js b/src/App.js index 55fa68c..f9ec1c5 100644 --- a/src/App.js +++ b/src/App.js @@ -1,6 +1,6 @@ import { BrowserRouter as Router, Route, Navigate , Routes } from 'react-router-dom'; import { Todo, Message, PersonalCenter, Bottom } from './pages/Bottom/index' -import { Home } from './pages/Home'; +import Home from './pages/Home'; import './pages/Bottom/index.css' import { NavBar, TabBar } from 'antd-mobile' function App() { diff --git a/src/pages/Home/index.js b/src/pages/Home/index.js index f498d7d..3e9b2b3 100644 --- a/src/pages/Home/index.js +++ b/src/pages/Home/index.js @@ -1,19 +1,20 @@ import React from 'react' -import { Swiper, CapsuleTabs, Grid } from 'antd-mobile' +import { Swiper, Grid } from 'antd-mobile' import axios from 'axios'; +import WidthUseNavigate from '../WidthUseNavigate'; import './index.css' import ImgZZ from './../../assets/images/nav-1.png' import ImgHZ from './../../assets/images/nav-2.png' import ImgDTZF from './../../assets/images/nav-3.png' import ImgQCZ from './../../assets/images/nav-4.png' -import { redirect, useNavigate } from 'react-router-dom'; + const localCatalog = [ { "imgSrc": ImgZZ, "title": "整租" ,"path":"/todo"}, { "imgSrc": ImgHZ, "title": "合租" ,"path":"/todo"}, { "imgSrc": ImgDTZF, "title": "地图找房" ,"path":"/message"}, { "imgSrc": ImgQCZ, "title": "去出租" ,"path":"/me"} ] -export class Home extends React.Component { +class HomeInner extends React.Component { state = { swipers: [] } @@ -48,7 +49,7 @@ export class Home extends React.Component { localCatalog.map((item,index) => ( { console.log("点击跳转") - this.props.navigate=item.path}}> + this.props.to(item.path)}}>

{item.title}

)) @@ -56,4 +57,8 @@ export class Home extends React.Component { }; -} \ No newline at end of file +} +// 使用高阶组件包裹当前类组件 +const Home = WidthUseNavigate(HomeInner); +// 导出包裹后的类组件 +export default Home; \ No newline at end of file