react-native路由的跳转问题

在开发react-native中碰到一个路由跳转的问题,例如 页面A是一个父组件,里面引用了一个子组件,子组件中有个按钮跳转到页面B,现在要从页面B返回到页面A,用this.props.navigation.navigate(页面A)这个方法,貌似可以解决,但是返回的动画又是不对的,而用goBack()方法的话,则是报错的,错误如下所示 图片描述

页面A的部分代码

import React, { Component } from 'react';
import {
    StyleSheet,
    View,
    Text,
    Image,
    Dimensions,
    ScrollView,
    AsyncStorage,
    TouchableOpacity
} from 'react-native';

const { width, height } = Dimensions.get('window')
import OrderBanner from './orderBanner'
import AlwaysBanner from './alwaysBanner'
import { userInfo, orderNum, coupCounts } from '../../api/getData'
export default class Index extends Component {
    static navigationOptions = ({ navigation }) => ({
        header: null,
    })

    constructor(props) {
        super(props)
        this.userInfo =

子组件的部分代码:


import React, { Component } from 'react';
import {
    StyleSheet,
    View,
    Text,
    Image,
    Dimensions,
    TouchableOpacity

} from 'react-native';

const { width, height } = Dimensions.get('window')


export default class OrderBanner extends Component {

    static navigationOptions = ({ navigation }) => ({
        header: null,
    })


    componentWillMount(){
        // console.log(this.props)
    }

各位大佬给看看,我真的一头雾水了,不胜感激~~~

阅读 5k
1 个回答
新手上路,请多包涵

印象中 goBack(页面名称),得传参数。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题