【发布时间】:2020-11-17 13:49:47
【问题描述】:
我正在研究 React Native,我是一个初学者,如果我的问题特别简单,请提前抱歉。
我目前在视图 (Home.Js) 中工作,而不是在 App.Js 中工作。在这个主页视图中,我有一个文本输入(用户名),我想获取用户单击按钮时输入的值。我观看了解释视频,但他们解释了如何在 App.Js 中执行此操作,当我在我的视图中实现它时它不起作用。这是我的代码。谢谢
#Here We Are in my Home View (Home.Js) not App.Js
import React from 'react';
import { Image, ImageBackground, StyleSheet, View, Text, TouchableOpacity, TextInput, Button } from 'react-native';
function Home(props) {
return (
<View style={styles.container}>
<View style={styles.header}>
<Image source={require('../assets/logo.png')}
style={styles.Logo}/>
<Image source={require('../assets/Joiny.png')}
style={styles.Logo}/>
</View>
<View style={styles.footer}>
<TextInput>Username</TextInput>
</View>
</View>
);
};
【问题讨论】:
标签: react-native view textinput