使用react實作一個tab元件的方法:1、透過「export default props => {...}」方式建立TAB button元件;2、透過「tab-group-layout.js」元件來傳“tabIndex”,並設定預設選取的tab效果;3、用react繼承“react.component”元件裡的onMouseOver和OnMouseOut方法即可。
本教學操作環境:windows7系統、react18.0.0版、Dell G3電腦。
怎麼使用react實作一個tab元件?
react寫入Tab元件
使用react寫入TAB欄元件和對應hover事件(背景:在用gatsby開發頁面時,遇到這樣的元件效果,順便記錄一下)
1、效果
## 預設選取的tab選取效果和滑鼠放上去的hover效果 當滑鼠滑過右側的tab時,也會有和第一個一樣的選取效果! 2、tab-button.js 元件import React from "react" import { css } from "@emotion/core" import { Link } from "gatsby" import jdyStyles from "./container.module.css" // TAB button 组件 export default props => { return (
import React from "react" import { css } from "@emotion/core" import { Link } from "gatsby" import ListLink from "../components/tab-button" import RegisterButton from "../components/round-button" export default ({ tabIndex }) => { return ({/* tab */}) }
产品介绍 成功案列 服务支持 资源中心
.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影片教學》
以上是怎麼使用react實作一個tab元件的詳細內容。更多資訊請關注PHP中文網其他相關文章!