刚入门react的新手如何利用react做一个tab功能,下面web建站小编给大家介绍一下功能的实现方法。
1、tab.js 组件
import React from "react"
import { css } from "@emotion/core"
import { Link } from "gatsby"
import jdyStyles from "./container.css"
// TAB button 组件
export default props => {
return (
<li css={css`font-size: 18px;margin-left:18px;margin-right: 18px;display:flex;flex-direction: column;align-items:center;justify-content:center`} >
<Link css={css`font-size: 18px;padding: 20px 12px;`}
className={ (props.selected?jdyStyles.header_hover_default:jdyStyles.header_hover) } to={props.to}>
{props.children}
</Link>
</li>
)
}
2、tab-layout.js 组件
import React from "react"
import { css } from "@emotion/core"
import { Link } from "gatsby"
import ListLink from "../components/tab"
import RegisterButton from "../components/round-button"
export default ({ tabIndex }) => {
return (
<div>
{/* tab */}
<ul style={{ listStyle: `none`, float: `right` }} css={css`display: flex;justify-content: space-between;align-items: center;`}>
<ListLink to="/official-site/" selected={(tabIndex==='official-site')}>产品介绍</ListLink>
<ListLink to="/about/" selected={(tabIndex==='about')}>成功案列</ListLink>
<ListLink to="/contact/" selected={(tabIndex==='contact')}>服务支持</ListLink>
<ListLink to="/sweet-pandas-eating-sweets/" selected={(tabIndex==='sweet-pandas-eating-sweets')}>资源中心</ListLink>
</ul>
</div>
)
}
3、container.css
.header_hover{
color: #333;
}
.header_hover_default{
color: #0084ff!important;
border-top: 3px solid #0084ff;
}
.header_hover:hover{
color: #0084ff!important;
border-top: 3px solid #0084ff;
}
上面是“利用react做一个tab功能(组件)”的全面内容,想了解更多关于 reactjs 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_2554.html
workflows工作流
一只迷人的黑豹ComfyUI工作流
一只漂亮的孔雀的尾巴完全由披萨制成ComfyUI工作流
1个黑发带着耳机项链的女孩ComfyUI工作流
1个很漂亮的单身小女孩ComfyUI工作流
一个孤独的身影在未来主义城市
一个质朴的木制窗户上放着各种葫芦、南瓜等
一桌精致的美食,桌上几杯白葡萄酒
外星人ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

3d文字360度旋转
利用CSS3做一个星级评分样式
做一个好玩的时钟翻牌效果
一个包含老黄历、佛历、道历、星宿等数据的日历网站
jquery鼠标滑过图片边框特效(jquery.focus-follow插件)
canvas空间文本射线
HTML5 Canvas 刻度尺











