我正在做一份登记表.

我创建了一个名为Regform的文件.组件目录下的js.

我无法获取文本注册的边界底部

这里是演示链接demo working link

请让我知道,我做错了什么

enter image description here

组件/注册表.js

import * as React from 'react';  

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


 export default class Regform extends React.Component {  
  render() {  
   return (  
    <View>  
     <Text style={styles.header}> Registration </Text> 

      <TextInput style = {styles.textinput}
      underlineColorAndroid = "transparent"
      placeholder = "Enter Your Name"
      placeholderTextColor = "#9a73ef"
      onChangeText = {this.handleName}/>

      <TextInput style = {styles.textinput}
      underlineColorAndroid = "transparent"
      placeholder = "Enter Your Email"
      placeholderTextColor = "#9a73ef"
      autoCapitalize = "none"
      onChangeText = {this.handleEmail}/>

    </View>  
   );  
  }  
 } 


 const styles = StyleSheet.create({  

      header: {  
        fontSize: 36,
        alignself: 'self',
        color: 'red',
        marginBottom: 30,
        borderBottomColor: 'red',
        borderBottomWidth: 2
      },
      textinput: {
        fontSize: 18,
        alignself: 'self',
        color: 'black',
        marginBottom: 30,
        borderBottomColor: 'grey',
        borderBottomWidth: 2
      }
  }); 

推荐答案

borderBottom似乎不适用于文本组件.你可以加一个View包装纸,再加上borderBottom,再加一个TextInput,再加上editable={false}

<View style={styles.headerWrapper}>
    <Text style={styles.header}> Registration </Text>
 </View>
...

headerWrapper: {
    borderBottomColor: 'red',
    borderBottomWidth: 2,
    marginBottom: 30,
},
header: {
    fontSize: 36,
    alignSelf: 'auto',
    color: 'red',

},

React-native相关问答推荐

React Native的TouchableOpacity不按类别获取样式名称

React Native 中的视图与 Flex 不占用相同的高度空间

React Native - Expo:fontFamily 'SimpleLineIcons' 不是系统字体,尚未通过 Font.loadAsync 加载

TextInput 防止 ScrollView 滚动

React.js - 为所有组件方法使用属性初始化器

ReactJS toLowerCase 不是一个函数

检索元素的父项时出错:找不到与给定名称android:TextAppearance.Material.Widget.Button.Colored匹配的资源

更改整个 React Native App 的语言

react-native: 'adb' 不是内部或外部命令、可运行程序或批处理文件

React Navigation 5 隐藏Drawer抽屉元素

React-Native Packager 失败:重复的模块名称

React Native 中的全屏图像

mapDispatchToProps:有什么意义吗?

未计算文件的 React-Native Bundle Error 错误 SHA-1

创建新的 react-native 元素时出现Unexpected token import错误

按钮的标题属性必须是字符串

React native - 以编程方式判断是否启用了远程 JS 调试

React-Native 元素卡在 :app:installDebug

以编程方式读取 app.json(或 exp.json)

是否可以将 Material UI 库与 React Native 一起使用?