Javascript 在NavigatorIOS react native中导航回
我正在我的react原生项目中测试NavigatorIOS。问题是,当我按下按钮从一个组件导航到另一个组件时,没有问题,但当我尝试使用NavigatorIOS生成的标题栏中的按钮返回时,我得到以下错误:“不支持的顶级事件”topScroll“已调度” 我使用react native cli=2.0.1和react native=0.56.0 注意:当我按下支持组件中的“返回”按钮时,一切正常 这是我的密码: 应用程序组件:Javascript 在NavigatorIOS react native中导航回,javascript,react-native,navigator-ios,Javascript,React Native,Navigator Ios,我正在我的react原生项目中测试NavigatorIOS。问题是,当我按下按钮从一个组件导航到另一个组件时,没有问题,但当我尝试使用NavigatorIOS生成的标题栏中的按钮返回时,我得到以下错误:“不支持的顶级事件”topScroll“已调度” 我使用react native cli=2.0.1和react native=0.56.0 注意:当我按下支持组件中的“返回”按钮时,一切正常 这是我的密码: 应用程序组件: import React, { Component } from "re
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 };
import React,{Component}来自“React”;
从“react native”导入{View,NavigatorIOS};
从“/src/components/index.js”导入{NavigationApp};
导出默认类应用程序扩展组件{
render(){
返回(
);
}
}
NavigationApp组件:
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 };
import React,{Component}来自“React”;
从“react native”导入{文本、视图、按钮、导航器};
从“/index.js”导入{Support};
类NavigationApp扩展组件{
导航支持=()=>{
这个是.props.navigator.push({
标题:“支持”,
构成部分:支助
});
};
render(){
const{containerStyle}=样式;
返回(
);
}
}
常量样式={
集装箱运输方式:{
弹性:1,
辩护内容:“中心”,
对齐项目:“中心”
}
};
导出{NavigationApp};
支持组件:
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 };
import React,{Component}来自“React”;
从“react native”导入{视图、文本、按钮};
类支持扩展了组件{
反作用=()=>{
this.props.navigator.pop();
};
render(){
返回(
您已进入支持页面
);
}
}
出口{支持};
解决方法是将初始组件包装在滚动视图中
<ScrollView>
// ... Initial Component code
</ScrollView>
// ... 初始组件代码
这是一个悬而未决的问题,您可以遵循线索是的,它起作用了,但我不希望该组件能够滚动。您可以使用
scrolldenabled={false}
禁用滚动。