Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么赢了';t<;TextInput/>;显示什么';正在打印什么?_Javascript_Ios_Reactjs_React Native_Expo - Fatal编程技术网

Javascript 为什么赢了';t<;TextInput/>;显示什么';正在打印什么?

Javascript 为什么赢了';t<;TextInput/>;显示什么';正在打印什么?,javascript,ios,reactjs,react-native,expo,Javascript,Ios,Reactjs,React Native,Expo,每当我在我的物理设备上点击第一个框中的Email时,我都看不到输入的内容。只有当我按Next进入密码框时,我才能看到电子邮件框中键入的内容。为什么会这样 下面是App.js的 import React, {Component} from 'react'; import {View, StyleSheet} from 'react-native'; import BackGround from './components/BackGround'; export default class App

每当我在我的物理设备上点击第一个
框中的
Email
时,我都看不到输入的内容。只有当我按
Next
进入
密码
框时,我才能看到
电子邮件
框中键入的内容。为什么会这样

下面是App.js的

import React, {Component} from 'react';
import {View, StyleSheet} from 'react-native';
import BackGround from './components/BackGround';

export default class App extends Component {
    render() {
        return(
            <View style={styles.back}>
                <BackGround/>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    back: {
        flex: 1
    }
});
import React, {Component} from 'react';
import {StyleSheet, TextInput, View, Text, TouchableOpacity, KeyboardAvoidingView} from 'react-native';

class Login extends Component {
    constructor(props) {
        super(props);
        this.state = {
            text: ''
        };
    }

    updateTextInput = text => this.setState({text});

    render() {
        return(
            <KeyboardAvoidingView behavior={"padding"} style={styles.container}>
                <View>
                    <TextInput
                        style={styles.input}
                        returnKeyType={"next"}
                        keyboardType={"email-address"}
                        autoCorrect={false}
                        onChangeText={this.updateTextInput}
                        value={this.state.text}
                    />

                    <TextInput
                        style={styles.input}
                        returnKeyType={"go"}
                        secureTextEntry
                    />

                    <TouchableOpacity>
                        <Text style={styles.loginAndCA}>Login</Text>
                    </TouchableOpacity>

                    <TouchableOpacity>
                        <Text style={styles.loginAndCA}>Create Account</Text>
                    </TouchableOpacity>
                </View>
            </KeyboardAvoidingView>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        padding: 20
    },

    input: {
        backgroundColor: '#DAE5FF',
        paddingBottom: 20,
        padding: 20,
        paddingHorizontal: 15,
        marginBottom: 10,
        borderRadius: 15,
    },

    loginAndCA: {
        fontSize: 40,
        textAlign: 'center',
        color: 'white',
        fontFamily: 'Bodoni 72 Smallcaps',
        paddingHorizontal: 10
    },

    buttons: {
        paddingBottom: 50
    }
});

export default Login;
import React, {Component} from 'react';
import {StyleSheet, Image, View} from 'react-native';
import Login from './Login';

export default class BackGround extends Component {
    render() {
        return(
            <View style={styles.first}>
                <Image style={styles.container} source={require('../pictures/smoke.jpg')}>
                    <View style={styles.second}>
                        <Login/>
                    </View>
                </Image>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        width: null,
        height: null,
        backgroundColor: 'rgba(0,0,0,0)',
        resizeMode: 'cover'
    },

    first: {
        flex: 1
    },

    second: {
       paddingTop: 290 // Moves both <TextInput> boxes down.
    }
});
下面是
BackGround.js

import React, {Component} from 'react';
import {View, StyleSheet} from 'react-native';
import BackGround from './components/BackGround';

export default class App extends Component {
    render() {
        return(
            <View style={styles.back}>
                <BackGround/>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    back: {
        flex: 1
    }
});
import React, {Component} from 'react';
import {StyleSheet, TextInput, View, Text, TouchableOpacity, KeyboardAvoidingView} from 'react-native';

class Login extends Component {
    constructor(props) {
        super(props);
        this.state = {
            text: ''
        };
    }

    updateTextInput = text => this.setState({text});

    render() {
        return(
            <KeyboardAvoidingView behavior={"padding"} style={styles.container}>
                <View>
                    <TextInput
                        style={styles.input}
                        returnKeyType={"next"}
                        keyboardType={"email-address"}
                        autoCorrect={false}
                        onChangeText={this.updateTextInput}
                        value={this.state.text}
                    />

                    <TextInput
                        style={styles.input}
                        returnKeyType={"go"}
                        secureTextEntry
                    />

                    <TouchableOpacity>
                        <Text style={styles.loginAndCA}>Login</Text>
                    </TouchableOpacity>

                    <TouchableOpacity>
                        <Text style={styles.loginAndCA}>Create Account</Text>
                    </TouchableOpacity>
                </View>
            </KeyboardAvoidingView>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        padding: 20
    },

    input: {
        backgroundColor: '#DAE5FF',
        paddingBottom: 20,
        padding: 20,
        paddingHorizontal: 15,
        marginBottom: 10,
        borderRadius: 15,
    },

    loginAndCA: {
        fontSize: 40,
        textAlign: 'center',
        color: 'white',
        fontFamily: 'Bodoni 72 Smallcaps',
        paddingHorizontal: 10
    },

    buttons: {
        paddingBottom: 50
    }
});

export default Login;
import React, {Component} from 'react';
import {StyleSheet, Image, View} from 'react-native';
import Login from './Login';

export default class BackGround extends Component {
    render() {
        return(
            <View style={styles.first}>
                <Image style={styles.container} source={require('../pictures/smoke.jpg')}>
                    <View style={styles.second}>
                        <Login/>
                    </View>
                </Image>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        width: null,
        height: null,
        backgroundColor: 'rgba(0,0,0,0)',
        resizeMode: 'cover'
    },

    first: {
        flex: 1
    },

    second: {
       paddingTop: 290 // Moves both <TextInput> boxes down.
    }
});
import React,{Component}来自'React';
从“react native”导入{样式表、图像、视图};
从“./Login”导入登录名;
导出默认类后台扩展组件{
render(){
返回(
);
}
}
const styles=StyleSheet.create({
容器:{
弹性:1,
为内容辩护:“中心”,
对齐项目:“居中”,
宽度:空,
高度:空,
背景颜色:“rgba(0,0,0,0)”,
resizeMode:“封面”
},
第一:{
弹性:1
},
第二:{
paddingTop:290//向下移动两个框。
}
});

您需要给它一个连接到状态的值,当该文本输入发生变化时,您将更新状态值:

export default class TextInputExample extends Component {
  constructor(props) {
    super(props);
    this.state = {
      text: ''
    };
  }
  updateTextInput = text => this.setState({ text })

  render() {
    return (
      <View style={{ flex: 1}}>
        <TextInput
          style={{height: 40}}
          placeholder="Type here!"
          onChangeText={this.updateTextInput}
          value={this.state.text}
        />
      </View>
    );
  }
}
导出默认类TextInputExample扩展组件{
建造师(道具){
超级(道具);
此.state={
文本:“”
};
}
updateTextInput=text=>this.setState({text})
render(){
返回(
);
}
}

您需要将
onTextChange
道具传递到
文本输入


你为什么要把它作为图像标签的子对象?对不起,我刚刚意识到我忘记给文本输入添加值了。如果仍然遇到问题,请尝试并发布更新的代码。