React tab切换页面

js:

import React from 'react'
import { Icon } from '@components'
import classNames from 'classnames'
import './index.scss'

class SystemSetup extends React.Component {
	constructor(props) {
		super(props)
		this.state = {
			tabActiveIndex: 0
		}
	}

	render() {
		let tabActiveIndex = this.state.tabActiveIndex;
		return (
			<div className="m-sys-wrap">
				<div className="m-sys-inner">
					<div className="m-sys-header">
						<Icon type="set" className="m-sys-set-icon"/>
						<span className="m-sys-set-text">系统设置</span>
						<ul className="m-sys-tab-wrap">
							<li className={"m-sys-tab " + (tabActiveIndex === 0 ? 'active': '')} onClick={this.handleTabClick.bind(this, 0)}>
								<Icon type="tuandui" className="m-sys-tab-icon"/>
								<span className="m-sys-tab-text">用户管理</span>
							</li>
							<li className={"m-sys-tab " + (tabActiveIndex === 1 ? 'active': '')} onClick={this.handleTabClick.bind(this, 1)}>
								<Icon type="peizhi" className="m-sys-tab-icon"/>
								<span className="m-sys-tab-text">基础配置</span>
							</li>
							<li className={"m-sys-tab " + (tabActiveIndex === 2 ? 'active': '')} onClick={this.handleTabClick.bind(this, 2)}>
								<Icon type="xiaoxi" className="m-sys-tab-icon"/>
								<span className="m-sys-tab-text">通知配置</span>
							</li>														
						</ul>
					</div>
					<div className="m-sys-content">
						<div className={"m-sys-view " + (tabActiveIndex === 0 ? 'active': '')}>
						0
						</div>
						<div className={"m-sys-view " + (tabActiveIndex === 1 ? 'active': '')}>
						1
						</div>
						<div className={"m-sys-view " + (tabActiveIndex === 2 ? 'active': '')}>
						2
						</div>												
					</div>
				</div>
			</div>
		);
	}
}

Object.assign(SystemSetup.prototype, {
	handleTabClick(tabActiveIndex) {
		this.setState({
			tabActiveIndex
		})
	}
})

export default SystemSetup

css:

.m-sys-wrap{position: absolute;top: 50px;left: 0;right: 0;bottom: 0;}
.m-sys-inner{position: absolute; width: 1280px;left: 50%;transform: translateX(-50%);}
.m-sys-header{margin: 30px 0 0 0;}
.m-sys-set-icon{position: absolute;top: 29px; color: #ffffff;}
.m-sys-set-text{margin: 0 0 0 26px; line-height: 20px;font-size: 14px;color: #ffffff;vertical-align: top;}
.m-sys-tab-wrap{display: inline-block; margin: 0 0 0 30px; padding: 0;}
.m-sys-tab{display: inline-block; position: relative;margin: 0 0 0 10px;  padding: 0 6px;line-height: 20px; color: #888888;list-style-type: none;background-color: #444444;border-radius: 2px;cursor: pointer;}
.m-sys-tab:hover{opacity: 0.8}
.m-sys-tab.active{color: #ffffff;background-color: #40677f;}
.m-sys-tab-icon{position: absolute;top: 1px; font-size: 14px;}
.m-sys-tab-text{display: inline-block; margin: 0 0 0 25px; font-size: 12px;}
.m-sys-view{display: none;color: #ffffff;font-size: 32px;}
.m-sys-view.active{display: block;}

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

徐同保

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值