<TextInput />在react-native / expo中不可编辑

时间:2020-03-17 07:00:49

标签: reactjs react-native

我是Learnig React-native,我使用Expo创建了一个应用。

import React, { useState, useEffect } from 'react';
import { Text, StyleSheet, View, Button, TouchableOpacity, Platform, TextInput } from 'react-native';

const HomeScreen = ({ navigation }) => {
    const [platform, setPlatform] = useState('');
    const [age, setAge] = useState('35')
    return (
        <View style={styles.container}>
           <Text>Enter Age</Text>

           <TextInput 
            style={styles.input}
            value={age}
            onChangeText = {(val) => {
                console.log(val)
                setAge(val)
            }}/>
        </View>
    );
};

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#fff',
        alignItems: 'center',
        justifyContent: 'center'
    },
    input: {
        borderWidth: 1,
        borderColor: '#777',
        padding: 8,
        margin: 10,
        width: 200,
        height: 35
    }
});

export default HomeScreen;

在android设备以及Genymotion中,一切正常运行,但不可编辑。

请帮助。

0 个答案:

没有答案