import React from 'react'
import { NavBar } from 'antd-mobile'
// 导入 withRouter 高阶组件
import { withRouter } from 'react-router-dom'
import "./index.scss"
function NavHeader({children,history,onLeftClick}) {
// 默认点击行为
const defaultHandler = () => history.go(-1)
return (
<NavBar
className="navbar"
mode="light"
icon={<i className="iconfont icon-back" />}
onLeftClick={onLeftClick || defaultHandler}
>
{children}
</NavBar>
)
}
//函数的返回值也是一个组件
export default withRouter(NavHeader)