好客租房163-css Module的应用

1使用css Modules修改NavHeader样式

2在样式文件中修改当前组件的样式

3对于组件库中已经有的全局样式 (比如:am-navber-title)

import React from 'react'
import { NavBar } from 'antd-mobile'
// 导入 withRouter 高阶组件
import { withRouter } from 'react-router-dom'
// 导入 props 校验的包
import PropTypes from 'prop-types'
// import "./index.scss"
import styles from "./index.module.scss"
// 添加props校验
NavHeader.propTypes = {
children: PropTypes.string.isRequired,
onLeftClick: PropTypes.func
}
function NavHeader({children,history,onLeftClick}) {
// 默认点击行为
const defaultHandler = () => history.go(-1)
return (
<NavBar
className={styles.navBar}
mode="light"
icon={<i className="iconfont icon-back" />}
onLeftClick={onLeftClick || defaultHandler}
>
{children}
</NavBar>
)
}
//函数的返回值也是一个组件
export default withRouter(NavHeader)

posted @   前端导师歌谣  阅读(37)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
点击右上角即可分享
微信分享提示