我正在我的反应原生项目中测试NavigatorIOS。 问题是当我按下按钮从一个组件导航到另一个组件时,没有问题,但是当我尝试返回 NavigatorIOS 生成的标题栏中的按钮时,我收到此错误:"不支持的顶级事件"topScroll"已调度"。
我使用 react-native-cli =2.0.1 和 react-native = 0.56.0
注意:当我按支持组件中的"返回"按钮时,一切正常。
这是我的代码:
应用组件:
import React, { Component } from "react";
import { View, NavigatorIOS } from "react-native";
import { NavigationApp } from "./src/components/index.js";
export default class App extends Component {
render() {
return (
<NavigatorIOS
style={{ flex: 1 }}
initialRoute={{
title: "Navigation app",
component: NavigationApp
}}
/>
);
}
}
导航应用程序组件:
import React, { Component } from "react";
import { Text, View, Button, NavigatorIOS } from "react-native";
import { Support } from "./index.js";
class NavigationApp extends Component {
navigateToSupport = () => {
this.props.navigator.push({
title: "Support",
component: Support
});
};
render() {
const { containerStyle } = styles;
return (
<View style={containerStyle}>
<Button
title="Go to support page"
onPress={this.navigateToSupport}
/>
</View>
);
}
}
const styles = {
containerStyle: {
flex: 1,
justifyContent: "center",
alignItems: "center"
}
};
export { NavigationApp };
支持组件:
import React, { Component } from "react";
import { View, Text, Button } from "react-native";
class Support extends Component {
backAction = () => {
this.props.navigator.pop();
};
render() {
return (
<View style={{ flex: 1, justifyContent: "center", alignItems:"center" }}>
<Text>You are in support page</Text>
<Button title="Go back" onPress={this.backAction} />
</View>
);
}
}
export { Support };
解决方法是将初始组件包装在ScrollView
<ScrollView>
// ... Initial Component code
</ScrollView>
这是一个悬而未决的问题,您可以在此处关注潜在客户