react-s-scrollable-tab-view

react-s-scrollable-tab-view

这是一个基于JavaScript原生实现的react组件,实现了滚动tabbar,滑动切换页面

github地址

这里写图片描述

安装

npm install react-s-scrollable-tab-view

使用

import ScrollableTabBarView, {ScrollableTabBar, DefaultTabBar} from 'components/ScrollableTabBarView/ScrollableTabBarView';

export default class Demo extends PureComponent {

    render() {
        return (
            <ScrollableTabBarView
                handleTab={this.handleTab}
                renderTabBar={() => <ScrollableTabBar/>}>
                <div tabLabel='title1' >content1</div>
                <div tabLabel='title2' >content2</div>
                <div tabLabel='title3' >content3</div>
                <div tabLabel='title4' >content4</div>
                <div tabLabel='title5' >content5</div>
                <div tabLabel='title6' >content6</div>
            </ScrollableTabBarView>
        )
    }
}

介绍

组件自带两种tabbar:
1.ScrollableTabBar
2.DefaultTabBar
同学们可自行选择合适的tabbar,也可自定义tabbar

属性

属性值类型默认值描述
initItemIndexnumber0初始化显示页面的下标
underlineStyleobjecttabbar下划线样式
textStyleobjecttabbar文字样式
activeTextColorstring333tabbar选中时文字高亮颜色
renderTabBaranyDefaultTabBar自定义tabbar
handleTabfunc页面切换回调

内置组件(Carousel, ScrollView)

1.Carousel

import {Carousel} from 'components/ScrollableTabBarView/ScrollableTabBarView';
const windows = {
    width: window.innerWidth,
    height: window.innerHeight
};
export default class DemoC extends PureComponent {

    render() {
        return (
            <Carousel className={styles.hcarousel}>
                <div className={styles.carouselItem} style={{width: windows.width, backgroundColor: '#000'}}/>
                <div className={styles.carouselItem} style={{width: windows.width, backgroundColor: 'red'}}/>
                <div className={styles.carouselItem} style={{width: windows.width, backgroundColor: 'yellow'}}/>
            </Carousel>
        )
    }
}

这里写图片描述

属性

属性值类型默认值描述
initItemnumber0初始化显示页面的下标
loopbooltrue是否循环滚动
autobooltrue是否自动滚动
autoplayTimenumber3000自动滚动间隔
indicatorbooltrue是否显示指示器
indicatorStyleobject默认样式指示器样式
indicatorDefany默认自定义指示器布局
indicatorActiveany默认自定义选中指示器布局
bounceboolfalse切换页面是否具有回弹效果
pageScrollEndfunc页面切换完成回调
itemClsstringitem class
itemStyleobjectitem 样式

2.ScrollView

import {ScrollView} from 'components/ScrollableTabBarView/ScrollableTabBarView';
const windows = {
    width: window.innerWidth,
    height: window.innerHeight
};
export default class DemoS extends PureComponent {

    render() {
        return (
            <ScrollView>
                <div className={styles.carouselItem} style={{backgroundColor: '#000'}}/>
                <div className={styles.carouselItem} style={{backgroundColor: 'red'}}/>
                <div className={styles.carouselItem} style={{backgroundColor: 'yellow'}}/>
                <div className={styles.carouselItem} style={{backgroundColor: '#000'}}/>
                <div className={styles.carouselItem} style={{backgroundColor: 'red'}}/>
                <div className={styles.carouselItem} style={{backgroundColor: 'yellow'}}/>
                <div className={styles.carouselItem} style={{backgroundColor: '#000'}}/>
                <div className={styles.carouselItem} style={{backgroundColor: 'red'}}/>
                <div className={styles.carouselItem} style={{backgroundColor: 'yellow'}}/>
            </ScrollView>
        )
    }
}

这里写图片描述

属性

属性值类型默认值描述
startYnumber0纵向初始化位置
startXnumber0横向初始化位置
horizontalboolfalse是否横向显示布局,默认纵向显示
bounceboolfalse滑动至顶/底部是否具有回弹效果
onScrollfunc滑动回调
onScrollEndfunc滑动结束回调
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值