2018年7月1日 星期日

[React Native]看著文件跌跌撞撞-TextInput


import React from 'react';
import { StyleSheet, Text, View , Button , TextInput } from 'react-native';
import Greeting from './components/Greeting'

export default class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      showText: '5566'
    };
  }
  render() {
    return (
      <View style={styles.container}>
        <Text>{ this.state.showText }</Text>
        <TextInput onChangeText={(showText)=> this.setState({showText})}></TextInput>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});


沒有留言:

張貼留言