美文网首页
身份认证-Demo3-(1)

身份认证-Demo3-(1)

作者: YH6666 | 来源:发表于2018-11-12 11:25 被阅读0次

import React, { Component } from "react";

import { View, Text, AsyncStorage, Button } from "react-native";

import { createSwitchNavigator } from "react-navigation";

import Demo3_1 from "./Demo3_1";

import Demo3_2 from "./Demo3_2";

class Demo extends Component {

  constructor(props) {

    super(props);

    this.state = {};

    this.show(); //自定义方法

  }

  show = async () => {

    const shows = await AsyncStorage.getItem("name");

    this.props.navigation.navigation(shows ? "Demo3_2" : ""); //判断是否为空,不为空跳转显示信息,为空不跳转

  };

  render() {

    return (

      <View style={{ flexDirection: "row", alignItems: "center" }}>

        <View style={{ margin: 10, width: 80 }}>

          <Button

            title="未登录"

            onPress={() => {

              this.props.navigation.navigate("Demo3_1");

            }}

          />

        </View>

        <Text> textInComponent </Text>

      </View>

    );

  }

}

const Demo3 = createSwitchNavigator({

  Demo: { screen: Demo },

  Demo3_2: { screen: Demo3_2 },

  Demo3_1: { screen: Demo3_1 }

});

export default Demo3;

相关文章

网友评论

      本文标题:身份认证-Demo3-(1)

      本文链接:https://www.haomeiwen.com/subject/ifbqfqtx.html