react-native - 样式中带有边距的 Native Base 按钮​​并不包含其中的文本

标签 react-native native-base

我使用 native 基础编写了一个基于 React Native 的应用程序。当我尝试在按钮中添加边距时,它不会显示按钮内的文本。我该如何修复它? 当我删除边距时,它工作正常。但当我把边距放回去时,它不起作用。我搜索了很多来源,但没有人给出任何解决方案。 这是代码:

import React, { Component } from 'react';
import { Platform, StyleSheet, View, Image } from 'react-native';
import FloatLabelInput from './src/components/FloatLabelInput';
import {Button, Text} from 'native-base'

type Props = {};
export default class App extends Component<Props> {
 render() {
  return (
   <View style={styles.container}>
    <Image
     style={styles.background_Image}
     source={require('./media/free-blurry-background-1636594.jpg')}
    />
    <Image source={require('./media/Save-the-Children-Logo.png')} 
    style={{height: '10%', width: '100%'}}/>
    <FloatLabelInput name='Username' security='false'/>
    <FloatLabelInput name='Password' security='true'/>
    <Button block rounded danger
        onPress={() => console.log('my first app')}
        style = {styles.button_style}
        // accessibilityLabel="Learn more about this purple button"
    > 
      <Text >LOGIN</Text>
    </Button>
  </View>
);
 }
}

const styles = StyleSheet.create({
 container: {
  flex: 1,
  justifyContent: 'center',
  alignItems: 'center',
  backgroundColor: '#C0C0C0',
 },
 welcome: {
  fontSize: 20,
  textAlign: 'center',
  margin: 10,
 },
instructions: {
 textAlign: 'center',
 color: '#333333',
 marginBottom: 5,
},
background_Image: {
 backgroundColor: '#ccc',
 flex: 1,
 position: 'absolute',
 width: '100%',
 height: '100%',
 justifyContent: 'center',
},
 button_style: {
 margin: '5%'
 }
 });

最佳答案

引用这个问题https://github.com/facebook/react-native/issues/19164我相信这是一个与百分比相关的bug .. 对于替代解决方案,请尝试使用 px

button_style: {
    margin: 5
}

关于react-native - 样式中带有边距的 Native Base 按钮​​并不包含其中的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53566324/

相关文章:

react-native - react 导航 : stack navigator with tab navigator is not working

javascript - 对对象使用 Promise

react-native - zIndex 不适用于 react 原生项目

android - 在 React Native 中安装 Nativebase 后应用程序无法运行

javascript - React Native 和 Native Base 中的两个子项具有相同的键

reactjs - react 原生依赖

javascript - 带有 xcode 模拟器的 react-native 有非常慢的警报

ios - React Native 开发中 Apple Health Kit 的虚假步骤数据

reactjs - EXPO React Native 应用程序无法从 Windows 加载

react-native - 如何根据 React Native 中的用户搜索从 api 获取数据?