在开发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)
}
各位大佬给看看,我真的一头雾水了,不胜感激~~~
印象中 goBack(页面名称),得传参数。