mCloud Design Mobile

mCloud Design Mobile

  • Docs
  • API
  • Help
  • Blog

›Component

Component

  • Button
  • SegmentedControl
  • SearchBar
  • Radio
  • Checkbox
  • Badge
  • Marquee
  • Switch
  • InputItem
  • NoticeBar
  • Textarea
  • List
  • Card
  • Picker
  • Label
  • EmptyView
  • Stepper
  • Tabs
  • DatePicker
  • Modal
  • Avatar
  • ActionSheet
  • ShareSheet

First Category

  • Button
  • Fifth Document

Tabs

Label

Basic Example:

import React  from 'react'
import {
    View,  StyleSheet ,
} from 'react-native'
import { Label } from 'mcloud-mobile';

export default class TabViewExample extends React.Component {
    state = {
        // eslint-disable-next-line react/no-unused-state
        index: 0,
        routes: [
            { key: '1', title: '新闻' },
            { key: '2', title: '视频' },
            { key: '3', title: '篮球' },
            { key: '4', title: '综艺' },
            { key: '5', title: '电影' },
        ],
    };
    _renderScene = ({ route }) => {
        switch (route.key) {
        case '1':
            return  (<View style={[styles.container, { backgroundColor: '#ff4081' }]} />)
        case '2':
            return  (<View style={[styles.container, { backgroundColor: '#673ab7' }]} />)
        case '3':
            return  (<View style={[styles.container, { backgroundColor: 'red' }]} />)
        case '4':
            return  (<View style={[styles.container, { backgroundColor: 'blue' }]} />)
        case '5':
            return  (<View style={[styles.container, { backgroundColor: 'black' }]} />)
        default:
            return null
        }
    }
    render() {
        return (
            <Tabs
                navigationState={this.state}
                UIColor="#586BFB"
                labelWidth={60}
                routesArray={this.state.routes}
                renderScene={this._renderScene}
                onIndexChange_Tabs={(index) => {
                    // eslint-disable-next-line react/no-unused-state
                    this.setState({ index })
                }}
            />
        )
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
    },
})


Props:

属性说明类型默认值
labelWidth标签长度number-
UIColor标题和下划线选中颜色string-
scrollEnabled标题栏是否滑动,默认为falsebool-
navigationState获取当前stateobject-
renderScene回调,返回一个react元素以呈现为分页的页面。接收包含路由作为参数的对象:func-
onIndexChange_Tabs回调,返回当前页面的index:func-
tabStyletab自定义样式Object无
labelStylelabel自定义样式Object无
indicatorStyleindicator自定义样式Object无
← StepperDatePicker →
  • Basic Example:
  • Props:
mCloud Design Mobile
Docs
Getting Started (or other categories)Guides (or other categories)API Reference (or other categories)
Community
User ShowcaseStack OverflowProject ChatTwitter
More
BlogGitHubStar
Facebook Open Source
Copyright © 2019 Your Name or Your Company Name