Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/407.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 反应本机导航:未定义已使用但尚未注册_Javascript_Android_React Native_Velo_React Native Navigation - Fatal编程技术网

Javascript 反应本机导航:未定义已使用但尚未注册

Javascript 反应本机导航:未定义已使用但尚未注册,javascript,android,react-native,velo,react-native-navigation,Javascript,Android,React Native,Velo,React Native Navigation,我正在尝试使用react native和创建一个简单的应用程序。我已经下载并使用了repo中的示例,试图找出问题所在,并查看了使用指南,但似乎一切都正常 但是,当应用程序启动时,会产生以下错误: Navigation.getRegisteredScreen:未定义已使用但尚未注册 我已经看过了屏幕注册,但是它的实现与示例或使用指南中的没有区别 版本信息: "react": "16.0.0-alpha.6", "react-native": "0.43.0", "react-native-elem

我正在尝试使用react native和创建一个简单的应用程序。我已经下载并使用了repo中的示例,试图找出问题所在,并查看了使用指南,但似乎一切都正常

但是,当应用程序启动时,会产生以下错误:

Navigation.getRegisteredScreen:未定义已使用但尚未注册

我已经看过了屏幕注册,但是它的实现与示例或使用指南中的没有区别

版本信息:

"react": "16.0.0-alpha.6",
"react-native": "0.43.0",
"react-native-elements": "^0.10.3",
"react-native-navigation": "^1.0.30",
"react-native-vector-icons": "^4.0.0"
目前,我正在开发Android而不是iOS,代码如下。欢迎任何指点:

index.android.js

import App from './src/app';
import {
    Platform
} from 'react-native';
import {Navigation} from 'react-native-navigation';

//Screen related book keeping
import {registerScreens} from './screens';
registerScreens();

//Create and store tab reference for use within Navigation constructor
const createTabs = () => {
    let tabs = [
        {
            label: 'One',
            screens: 'TestApp.HomeScreen',
            icon: require('../img/one.png'),
            selectedIcon: require('../img/one_selected.png'),
            title: 'Home'
        },
        {
            label: 'Two',
            screens: 'TestApp.CodeScreen',
            icon: require('../img/two.png'),
            selectedIcon: require('../img/two_selected.png'),
            title: 'Codes'
        },
    ];
    return tabs;
};
//this will start the app
Navigation.startTabBasedApp({
    tabs: createTabs(),
    tabsStyle: {
        tabBarBackgroundColor: '#0f2362',
        tabBarButtonColor: '#ffffff',
        tabBarSelectedButtonColor: '#63d7cc'
    },
    appStyle: {
        orientation: 'portrait'
    },
});
import { Navigation } from 'react-native-navigation';
import HomeScreen from './HomeScreen';
import CodeScreen from './CodeScreen';

// register all screens of the app (including internal ones)
export function registerScreens () {
  Navigation.registerComponent('TestApp.HomeScreen', () => HomeScreen);
  Navigation.registerComponent('TestApp.CodeScreen', () => CodeScreen);
}
import React, { Component } from 'react';
import {
  Text,
  View,
  ScrollView,
  TouchableOpacity,
  StyleSheet,
  Alert
} from 'react-native';
import { Navigation, Screen } from 'react-native-navigation';

export default class CodeScreen extends Component {
      constructor(props) {
    super(props);
  }

  render() {
    return (
      <View style={styles.container}>

        <TouchableOpacity>
          <Text style={styles.button}>Change Buttons</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Change Title</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Switch To Tab#1</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Set Tab Badge</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Toggle Tabs</Text>
        </TouchableOpacity>

      </View>
    );
  }
 }

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
    backgroundColor: 'white'
  },
  button: {
    textAlign: 'center',
    fontSize: 18,
    marginBottom: 10,
    marginTop:10,
    color: 'blue'
  }
});
import React, { Component } from 'react';
import {
  Text,
  View,
  TouchableOpacity,
  StyleSheet,
  Alert,
  Platform
} from 'react-native';
import { Navigation, Screen } from 'react-native-navigation';

export default class HomeScreen extends Component {
  constructor(props) {
    super(props);
    // if you want to listen on navigator events, set this up
  }

  render() {
    return (
      <View style={{flex: 1, padding: 20}}>
        <TouchableOpacity>
          <Text style={styles.button}>Push Plain Screen</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Push Styled Screen</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Show Modal Screen</Text>
        </TouchableOpacity>

        {
          Platform.OS === 'ios' ?
            <TouchableOpacity>
              <Text style={styles.button}>Show LightBox</Text>
            </TouchableOpacity> : false
        }

        {
          Platform.OS === 'ios' ?
            <TouchableOpacity>
              <Text style={styles.button}>Show In-App Notification</Text>
            </TouchableOpacity> : false
        }

        <TouchableOpacity>
          <Text style={styles.button}>Show Single Screen App</Text>
        </TouchableOpacity>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  button: {
    textAlign: 'center',
    fontSize: 18,
    marginBottom: 10,
    marginTop: 10,
    color: 'blue'
  }
});
app.js

import App from './src/app';
import {
    Platform
} from 'react-native';
import {Navigation} from 'react-native-navigation';

//Screen related book keeping
import {registerScreens} from './screens';
registerScreens();

//Create and store tab reference for use within Navigation constructor
const createTabs = () => {
    let tabs = [
        {
            label: 'One',
            screens: 'TestApp.HomeScreen',
            icon: require('../img/one.png'),
            selectedIcon: require('../img/one_selected.png'),
            title: 'Home'
        },
        {
            label: 'Two',
            screens: 'TestApp.CodeScreen',
            icon: require('../img/two.png'),
            selectedIcon: require('../img/two_selected.png'),
            title: 'Codes'
        },
    ];
    return tabs;
};
//this will start the app
Navigation.startTabBasedApp({
    tabs: createTabs(),
    tabsStyle: {
        tabBarBackgroundColor: '#0f2362',
        tabBarButtonColor: '#ffffff',
        tabBarSelectedButtonColor: '#63d7cc'
    },
    appStyle: {
        orientation: 'portrait'
    },
});
import { Navigation } from 'react-native-navigation';
import HomeScreen from './HomeScreen';
import CodeScreen from './CodeScreen';

// register all screens of the app (including internal ones)
export function registerScreens () {
  Navigation.registerComponent('TestApp.HomeScreen', () => HomeScreen);
  Navigation.registerComponent('TestApp.CodeScreen', () => CodeScreen);
}
import React, { Component } from 'react';
import {
  Text,
  View,
  ScrollView,
  TouchableOpacity,
  StyleSheet,
  Alert
} from 'react-native';
import { Navigation, Screen } from 'react-native-navigation';

export default class CodeScreen extends Component {
      constructor(props) {
    super(props);
  }

  render() {
    return (
      <View style={styles.container}>

        <TouchableOpacity>
          <Text style={styles.button}>Change Buttons</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Change Title</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Switch To Tab#1</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Set Tab Badge</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Toggle Tabs</Text>
        </TouchableOpacity>

      </View>
    );
  }
 }

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
    backgroundColor: 'white'
  },
  button: {
    textAlign: 'center',
    fontSize: 18,
    marginBottom: 10,
    marginTop:10,
    color: 'blue'
  }
});
import React, { Component } from 'react';
import {
  Text,
  View,
  TouchableOpacity,
  StyleSheet,
  Alert,
  Platform
} from 'react-native';
import { Navigation, Screen } from 'react-native-navigation';

export default class HomeScreen extends Component {
  constructor(props) {
    super(props);
    // if you want to listen on navigator events, set this up
  }

  render() {
    return (
      <View style={{flex: 1, padding: 20}}>
        <TouchableOpacity>
          <Text style={styles.button}>Push Plain Screen</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Push Styled Screen</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Show Modal Screen</Text>
        </TouchableOpacity>

        {
          Platform.OS === 'ios' ?
            <TouchableOpacity>
              <Text style={styles.button}>Show LightBox</Text>
            </TouchableOpacity> : false
        }

        {
          Platform.OS === 'ios' ?
            <TouchableOpacity>
              <Text style={styles.button}>Show In-App Notification</Text>
            </TouchableOpacity> : false
        }

        <TouchableOpacity>
          <Text style={styles.button}>Show Single Screen App</Text>
        </TouchableOpacity>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  button: {
    textAlign: 'center',
    fontSize: 18,
    marginBottom: 10,
    marginTop: 10,
    color: 'blue'
  }
});
/src/screens/index.android.js

import App from './src/app';
import {
    Platform
} from 'react-native';
import {Navigation} from 'react-native-navigation';

//Screen related book keeping
import {registerScreens} from './screens';
registerScreens();

//Create and store tab reference for use within Navigation constructor
const createTabs = () => {
    let tabs = [
        {
            label: 'One',
            screens: 'TestApp.HomeScreen',
            icon: require('../img/one.png'),
            selectedIcon: require('../img/one_selected.png'),
            title: 'Home'
        },
        {
            label: 'Two',
            screens: 'TestApp.CodeScreen',
            icon: require('../img/two.png'),
            selectedIcon: require('../img/two_selected.png'),
            title: 'Codes'
        },
    ];
    return tabs;
};
//this will start the app
Navigation.startTabBasedApp({
    tabs: createTabs(),
    tabsStyle: {
        tabBarBackgroundColor: '#0f2362',
        tabBarButtonColor: '#ffffff',
        tabBarSelectedButtonColor: '#63d7cc'
    },
    appStyle: {
        orientation: 'portrait'
    },
});
import { Navigation } from 'react-native-navigation';
import HomeScreen from './HomeScreen';
import CodeScreen from './CodeScreen';

// register all screens of the app (including internal ones)
export function registerScreens () {
  Navigation.registerComponent('TestApp.HomeScreen', () => HomeScreen);
  Navigation.registerComponent('TestApp.CodeScreen', () => CodeScreen);
}
import React, { Component } from 'react';
import {
  Text,
  View,
  ScrollView,
  TouchableOpacity,
  StyleSheet,
  Alert
} from 'react-native';
import { Navigation, Screen } from 'react-native-navigation';

export default class CodeScreen extends Component {
      constructor(props) {
    super(props);
  }

  render() {
    return (
      <View style={styles.container}>

        <TouchableOpacity>
          <Text style={styles.button}>Change Buttons</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Change Title</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Switch To Tab#1</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Set Tab Badge</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Toggle Tabs</Text>
        </TouchableOpacity>

      </View>
    );
  }
 }

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
    backgroundColor: 'white'
  },
  button: {
    textAlign: 'center',
    fontSize: 18,
    marginBottom: 10,
    marginTop:10,
    color: 'blue'
  }
});
import React, { Component } from 'react';
import {
  Text,
  View,
  TouchableOpacity,
  StyleSheet,
  Alert,
  Platform
} from 'react-native';
import { Navigation, Screen } from 'react-native-navigation';

export default class HomeScreen extends Component {
  constructor(props) {
    super(props);
    // if you want to listen on navigator events, set this up
  }

  render() {
    return (
      <View style={{flex: 1, padding: 20}}>
        <TouchableOpacity>
          <Text style={styles.button}>Push Plain Screen</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Push Styled Screen</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Show Modal Screen</Text>
        </TouchableOpacity>

        {
          Platform.OS === 'ios' ?
            <TouchableOpacity>
              <Text style={styles.button}>Show LightBox</Text>
            </TouchableOpacity> : false
        }

        {
          Platform.OS === 'ios' ?
            <TouchableOpacity>
              <Text style={styles.button}>Show In-App Notification</Text>
            </TouchableOpacity> : false
        }

        <TouchableOpacity>
          <Text style={styles.button}>Show Single Screen App</Text>
        </TouchableOpacity>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  button: {
    textAlign: 'center',
    fontSize: 18,
    marginBottom: 10,
    marginTop: 10,
    color: 'blue'
  }
});
/src/screens/CodeScreen.js

import App from './src/app';
import {
    Platform
} from 'react-native';
import {Navigation} from 'react-native-navigation';

//Screen related book keeping
import {registerScreens} from './screens';
registerScreens();

//Create and store tab reference for use within Navigation constructor
const createTabs = () => {
    let tabs = [
        {
            label: 'One',
            screens: 'TestApp.HomeScreen',
            icon: require('../img/one.png'),
            selectedIcon: require('../img/one_selected.png'),
            title: 'Home'
        },
        {
            label: 'Two',
            screens: 'TestApp.CodeScreen',
            icon: require('../img/two.png'),
            selectedIcon: require('../img/two_selected.png'),
            title: 'Codes'
        },
    ];
    return tabs;
};
//this will start the app
Navigation.startTabBasedApp({
    tabs: createTabs(),
    tabsStyle: {
        tabBarBackgroundColor: '#0f2362',
        tabBarButtonColor: '#ffffff',
        tabBarSelectedButtonColor: '#63d7cc'
    },
    appStyle: {
        orientation: 'portrait'
    },
});
import { Navigation } from 'react-native-navigation';
import HomeScreen from './HomeScreen';
import CodeScreen from './CodeScreen';

// register all screens of the app (including internal ones)
export function registerScreens () {
  Navigation.registerComponent('TestApp.HomeScreen', () => HomeScreen);
  Navigation.registerComponent('TestApp.CodeScreen', () => CodeScreen);
}
import React, { Component } from 'react';
import {
  Text,
  View,
  ScrollView,
  TouchableOpacity,
  StyleSheet,
  Alert
} from 'react-native';
import { Navigation, Screen } from 'react-native-navigation';

export default class CodeScreen extends Component {
      constructor(props) {
    super(props);
  }

  render() {
    return (
      <View style={styles.container}>

        <TouchableOpacity>
          <Text style={styles.button}>Change Buttons</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Change Title</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Switch To Tab#1</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Set Tab Badge</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Toggle Tabs</Text>
        </TouchableOpacity>

      </View>
    );
  }
 }

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
    backgroundColor: 'white'
  },
  button: {
    textAlign: 'center',
    fontSize: 18,
    marginBottom: 10,
    marginTop:10,
    color: 'blue'
  }
});
import React, { Component } from 'react';
import {
  Text,
  View,
  TouchableOpacity,
  StyleSheet,
  Alert,
  Platform
} from 'react-native';
import { Navigation, Screen } from 'react-native-navigation';

export default class HomeScreen extends Component {
  constructor(props) {
    super(props);
    // if you want to listen on navigator events, set this up
  }

  render() {
    return (
      <View style={{flex: 1, padding: 20}}>
        <TouchableOpacity>
          <Text style={styles.button}>Push Plain Screen</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Push Styled Screen</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Show Modal Screen</Text>
        </TouchableOpacity>

        {
          Platform.OS === 'ios' ?
            <TouchableOpacity>
              <Text style={styles.button}>Show LightBox</Text>
            </TouchableOpacity> : false
        }

        {
          Platform.OS === 'ios' ?
            <TouchableOpacity>
              <Text style={styles.button}>Show In-App Notification</Text>
            </TouchableOpacity> : false
        }

        <TouchableOpacity>
          <Text style={styles.button}>Show Single Screen App</Text>
        </TouchableOpacity>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  button: {
    textAlign: 'center',
    fontSize: 18,
    marginBottom: 10,
    marginTop: 10,
    color: 'blue'
  }
});
import React,{Component}来自'React';
进口{
文本,
看法
滚动视图,
可触摸不透明度,
样式表,
警觉的
}从“反应本机”;
从“react native Navigation”导入{Navigation,Screen};
导出默认类CodeScreen扩展组件{
建造师(道具){
超级(道具);
}
render(){
返回(
更改按钮
改名
切换到选项卡1
设置标签徽章
切换选项卡
);
}
}
const styles=StyleSheet.create({
容器:{
弹性:1,
填充:20,
背景颜色:“白色”
},
按钮:{
textAlign:'中心',
尺码:18,
marginBottom:10,
玛金托普:10,
颜色:“蓝色”
}
});
/src/screens/HomeScreen.js

import App from './src/app';
import {
    Platform
} from 'react-native';
import {Navigation} from 'react-native-navigation';

//Screen related book keeping
import {registerScreens} from './screens';
registerScreens();

//Create and store tab reference for use within Navigation constructor
const createTabs = () => {
    let tabs = [
        {
            label: 'One',
            screens: 'TestApp.HomeScreen',
            icon: require('../img/one.png'),
            selectedIcon: require('../img/one_selected.png'),
            title: 'Home'
        },
        {
            label: 'Two',
            screens: 'TestApp.CodeScreen',
            icon: require('../img/two.png'),
            selectedIcon: require('../img/two_selected.png'),
            title: 'Codes'
        },
    ];
    return tabs;
};
//this will start the app
Navigation.startTabBasedApp({
    tabs: createTabs(),
    tabsStyle: {
        tabBarBackgroundColor: '#0f2362',
        tabBarButtonColor: '#ffffff',
        tabBarSelectedButtonColor: '#63d7cc'
    },
    appStyle: {
        orientation: 'portrait'
    },
});
import { Navigation } from 'react-native-navigation';
import HomeScreen from './HomeScreen';
import CodeScreen from './CodeScreen';

// register all screens of the app (including internal ones)
export function registerScreens () {
  Navigation.registerComponent('TestApp.HomeScreen', () => HomeScreen);
  Navigation.registerComponent('TestApp.CodeScreen', () => CodeScreen);
}
import React, { Component } from 'react';
import {
  Text,
  View,
  ScrollView,
  TouchableOpacity,
  StyleSheet,
  Alert
} from 'react-native';
import { Navigation, Screen } from 'react-native-navigation';

export default class CodeScreen extends Component {
      constructor(props) {
    super(props);
  }

  render() {
    return (
      <View style={styles.container}>

        <TouchableOpacity>
          <Text style={styles.button}>Change Buttons</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Change Title</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Switch To Tab#1</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Set Tab Badge</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Toggle Tabs</Text>
        </TouchableOpacity>

      </View>
    );
  }
 }

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 20,
    backgroundColor: 'white'
  },
  button: {
    textAlign: 'center',
    fontSize: 18,
    marginBottom: 10,
    marginTop:10,
    color: 'blue'
  }
});
import React, { Component } from 'react';
import {
  Text,
  View,
  TouchableOpacity,
  StyleSheet,
  Alert,
  Platform
} from 'react-native';
import { Navigation, Screen } from 'react-native-navigation';

export default class HomeScreen extends Component {
  constructor(props) {
    super(props);
    // if you want to listen on navigator events, set this up
  }

  render() {
    return (
      <View style={{flex: 1, padding: 20}}>
        <TouchableOpacity>
          <Text style={styles.button}>Push Plain Screen</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Push Styled Screen</Text>
        </TouchableOpacity>

        <TouchableOpacity>
          <Text style={styles.button}>Show Modal Screen</Text>
        </TouchableOpacity>

        {
          Platform.OS === 'ios' ?
            <TouchableOpacity>
              <Text style={styles.button}>Show LightBox</Text>
            </TouchableOpacity> : false
        }

        {
          Platform.OS === 'ios' ?
            <TouchableOpacity>
              <Text style={styles.button}>Show In-App Notification</Text>
            </TouchableOpacity> : false
        }

        <TouchableOpacity>
          <Text style={styles.button}>Show Single Screen App</Text>
        </TouchableOpacity>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  button: {
    textAlign: 'center',
    fontSize: 18,
    marginBottom: 10,
    marginTop: 10,
    color: 'blue'
  }
});
import React,{Component}来自'React';
进口{
文本,
看法
可触摸不透明度,
样式表,
警觉的,
站台
}从“反应本机”;
从“react native Navigation”导入{Navigation,Screen};
导出默认类主屏幕扩展组件{
建造师(道具){
超级(道具);
//如果要侦听navigator事件,请设置此选项
}
render(){
返回(
推平筛
推式屏幕
显示模式屏幕
{
Platform.OS==='ios'?
展示灯箱
:错
}
{
Platform.OS==='ios'?
显示应用内通知
:错
}
显示单屏幕应用程序
);
}
}
const styles=StyleSheet.create({
按钮:{
textAlign:'中心',
尺码:18,
marginBottom:10,
玛金托普:10,
颜色:“蓝色”
}
});

您使用了错误的键来指定
屏幕。在代码中:

const createTabs=()=>{
设制表符=[{
标签:"一",,
屏幕:“TestApp.HomeScreen”,
图标:require('../img/one.png'),
selectedIcon:require('../img/one_selected.png'),
标题:“家”
},
{
标签:"两个",,
屏幕:“TestApp.CodeScreen”,
图标:require('../img/two.png'),
selectedIcon:require('../img/two_selected.png'),
标题:“代码”
},
];
返回标签;
};