import React, { Component } from 'react' import { StyleSheet, View, Text, Image, ScrollView } from 'react-native' import { height, width } from '../../utils/base'; export interface Props { tabs: Array } export interface State { } export default class ScrollTabView extends React.Component { constructor(props: Props | Readonly) { super(props); } componentDidMount() { } componentWillUnmount() { } public readonly state: Readonly = { } public scrollViewRef = null rendTabConatiner = (item, index, key) => { let { tabs } = this.props console.log("item", item) return ( {item} ) } onchangeTab = (i) => { console.log("999", i) this.scrollViewRef.scrollTo({ x: width * i, y: 0, animated: true }) } render() { let { tabs, children } = this.props console.log(children) return ( { this.scrollViewRef = c }} pagingEnabled={true} horizontal={true} showsHorizontalScrollIndicator={false} style={[styles.main, { width: width, height: height }]}> { children.map((item, index) => this.rendTabConatiner(item, index, index)) } ); } } const styles = StyleSheet.create({ main: { flex: 1, width: width, } })