崩溃崩溃 引入 StackNavigator 就报错 求大神



  • cc156855-5a00-40d2-a7e5-304c4ca18fc5-image.png

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

    import {StackNavigator} from 'react-navigation';

    export default class App extends Component {
    constructor (props) {
    super (props)
    this.state = {
    login: null,
    password:null
    }
    }

    render() {
        return(
            <View style={{flex: 1, column: 'row'}}>
                <View style={{flex: 1, justifyContent: "center", alignItems: "center"}}>
                    <Text style={styles.bigBlue}>Hello, world!</Text>
                </View>
                <View style={{flex: 1, justifyContent: "center", alignItems: "center"}}>
                    <TextInput onChangeText={(text) => this.state.login = text}
                               style={{
                                   height: 40,
                                   width: 300,
                                   bottom: 20,
                                   borderBottomColor: 'gray',
                                   borderBottomWidth: 1
                               }}
                               placeholder="E-Mail"/>
                    <TextInput onChangeText={(text) => this.state.password = text}
                               style={{
                                   height: 40,
                                   bottom: 20,
                                   width: 300,
                                   borderBottomColor: 'gray',
                                   borderBottomWidth: 1
                               }}
                               placeholder="Password"/>
                    <Button title="Login"
                            onPress={() => {onPressLearnMore(this.state)}}
                            color="blue"/>
                </View>
                <View style={{flex: 1}}>
                </View>
            </View>
        );
    
        function onPressLearnMore(state) {
            let formData = new FormData();
            formData.append('login',state.login);
            formData.append('password',state.password);
    
            fetch("http://192.168.0.152:8104/webLogin/login", {
                method: "POST",
                headers: {
                    // "Content-Type": "multipart/form-data"
                },
                body: formData
            }).then(function (res) {
                console.log("fetch request ", JSON.stringify(res.ok));
                if(res.ok) {
                    res.json().then(function (json) {
                        console.info(json.code);
                        if(json.code===200){
                            alert(json.message);
                        }else{
                            alert(json.message);
                        }
                    });
                }
            }).catch(function (e) {
                console.log("fetch fail"+e);
            });
        }
    }
    

    };

    const styles = StyleSheet.create({
    bigBlue: {
    color: 'black',
    fontWeight: 'bold',
    fontSize: 30,
    }
    });

    • 列表


  • ![替代文字](批注 2019-12-23 110810.png 图片地址)
    哪个版本的 4.X 导航 这样引


Log in to reply