簡體   English   中英

反應原生的按鈕不可見

[英]Buttons invisibles on react native

我想在輸入字段上方連續顯示 2 個按鈕

我在 android 設備上測試這個,兩個按鈕都是不可見的 我在 expo 和一個物理設備上測試這個我在終端或消息上看不到任何錯誤

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

const StartGameScreen = props => {
    return(
        <View style={styles.screen}>
            <Text style={styles.title}>Start a new game!</Text>
            <View style={styles.inputContainer}>
                <Text>Select a number</Text>
                <TextInput/>
                <View style={styles.buttonContainer}>
                <Button title="Reset" onPress={() => {}} />
                <Button title="confirm" onPress={() => {}} />
                </View>
            </View>
        </View>
    );
};

const styles = StyleSheet.create({
    screen:{
        flex:1,
        padding: 10,
        alignItems:'center',
        justifyContent: 'flex-start',
    },
    title:{
        fontSize: 20,
        marginVertical: 10, 
    },
    inputContainer:{
        width: 300,
        maxWidth: '80%',
        alignItems: 'center'
    },
    buttonContainer:{
        flexDirection:'row',
        width:'100%',
        justifyContent: 'space-between',
        paddingHorizontal: 15
    }
});

export default StartGameScreen;

我檢查了您的代碼,它運行良好:

我使用 React Native CLI 生成了我的項目

 react-native init AwesomeProject

最好使用 React Native CLI 而不是 Expo

如果它不起作用,請為按鈕或其他組件使用看起來像“引導程序”的 Reac Native UI 庫:

示例

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM