高阶组件包裹跳转
This commit is contained in:
parent
9ed09350f0
commit
49d6146e3f
|
@ -1,6 +1,6 @@
|
||||||
import { BrowserRouter as Router, Route, Navigate , Routes } from 'react-router-dom';
|
import { BrowserRouter as Router, Route, Navigate , Routes } from 'react-router-dom';
|
||||||
import { Todo, Message, PersonalCenter, Bottom } from './pages/Bottom/index'
|
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 './pages/Bottom/index.css'
|
||||||
import { NavBar, TabBar } from 'antd-mobile'
|
import { NavBar, TabBar } from 'antd-mobile'
|
||||||
function App() {
|
function App() {
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { Swiper, CapsuleTabs, Grid } from 'antd-mobile'
|
import { Swiper, Grid } from 'antd-mobile'
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import WidthUseNavigate from '../WidthUseNavigate';
|
||||||
import './index.css'
|
import './index.css'
|
||||||
import ImgZZ from './../../assets/images/nav-1.png'
|
import ImgZZ from './../../assets/images/nav-1.png'
|
||||||
import ImgHZ from './../../assets/images/nav-2.png'
|
import ImgHZ from './../../assets/images/nav-2.png'
|
||||||
import ImgDTZF from './../../assets/images/nav-3.png'
|
import ImgDTZF from './../../assets/images/nav-3.png'
|
||||||
import ImgQCZ from './../../assets/images/nav-4.png'
|
import ImgQCZ from './../../assets/images/nav-4.png'
|
||||||
import { redirect, useNavigate } from 'react-router-dom';
|
|
||||||
const localCatalog = [
|
const localCatalog = [
|
||||||
{ "imgSrc": ImgZZ, "title": "整租" ,"path":"/todo"},
|
{ "imgSrc": ImgZZ, "title": "整租" ,"path":"/todo"},
|
||||||
{ "imgSrc": ImgHZ, "title": "合租" ,"path":"/todo"},
|
{ "imgSrc": ImgHZ, "title": "合租" ,"path":"/todo"},
|
||||||
{ "imgSrc": ImgDTZF, "title": "地图找房" ,"path":"/message"},
|
{ "imgSrc": ImgDTZF, "title": "地图找房" ,"path":"/message"},
|
||||||
{ "imgSrc": ImgQCZ, "title": "去出租" ,"path":"/me"}
|
{ "imgSrc": ImgQCZ, "title": "去出租" ,"path":"/me"}
|
||||||
]
|
]
|
||||||
export class Home extends React.Component {
|
class HomeInner extends React.Component {
|
||||||
state = {
|
state = {
|
||||||
swipers: []
|
swipers: []
|
||||||
}
|
}
|
||||||
|
@ -48,7 +49,7 @@ export class Home extends React.Component {
|
||||||
localCatalog.map((item,index) => (
|
localCatalog.map((item,index) => (
|
||||||
<Grid.Item key={index} onClick={()=>{
|
<Grid.Item key={index} onClick={()=>{
|
||||||
console.log("点击跳转")
|
console.log("点击跳转")
|
||||||
this.props.navigate=item.path}}>
|
this.props.to(item.path)}}>
|
||||||
<div ><img src={item.imgSrc} /><h2>{item.title}</h2></div>
|
<div ><img src={item.imgSrc} /><h2>{item.title}</h2></div>
|
||||||
</Grid.Item>
|
</Grid.Item>
|
||||||
))
|
))
|
||||||
|
@ -57,3 +58,7 @@ export class Home extends React.Component {
|
||||||
</div>
|
</div>
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
// 使用高阶组件包裹当前类组件
|
||||||
|
const Home = WidthUseNavigate(HomeInner);
|
||||||
|
// 导出包裹后的类组件
|
||||||
|
export default Home;
|
Loading…
Reference in New Issue