刚入门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工作流
一群邪恶的小黄人ComfyUI工作流
一碗热气腾腾的拉面ComfyUI工作流
文生图工作流:一幅海底睡莲,碧海蓝天comfyui工
树上一个快乐的猕猴桃ComfyUI工作流
一个美丽的女孩穿着花瓣做的衣服
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

在线生成金属文字
css3+js菜单点击动态效果
如何利用svg做一个有趣的loading动画加载
制作一个好玩的倒计时
利用html5+css3实现滚雪球效果(附代码)
利用js+css3做一个小鱼游泳特效
3d文字360度旋转
利用js做一个炫酷音乐背景效果







