当QRcode读取库时,未定义不是对象(计算'this.pros.Navigator.Push [英] undefined is not an object (evaluating 'this.props.navigator.push') while QRcode reading library

查看:27
本文介绍了当QRcode读取库时,未定义不是对象(计算'this.pros.Navigator.Push的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用REACT Native读取QRcode 然后我安装库

这是我的代码

  'use strict';

    var React = require('react-native');
    var {
      AppRegistry,
      StyleSheet,
      Text,
      View,
      TouchableOpacity,
      NavigatorIOS,
    } = React;

    var QRCodeScreen = require('./QRCodeScreen');   

  var cameraApp = React.createClass({
      render: function() {
        return (
          <NavigatorIOS
            style={styles.container,{ width:100,height:500}}
            initialRoute={{
              title: 'Index',
              backButtonTitle: 'Back',
              component: Index,
            }}
          />        
        );
      }
    });    

    var Index = React.createClass({        
      render: function() {
        return (
          <View style={styles.contentContainer}>
            <TouchableOpacity onPress={this._onPressQRCode} >
              <Text>Read QRCode</Text>
            </TouchableOpacity>
          </View>
        );
      },        
      _onPressQRCode: function() {
        this.props.navigator.push({
          component: QRCodeScreen,
          title: 'QRCode',
          passProps: {
            onSucess: this._onSucess,
          },
        });
      },        
      _onSucess: function(result) {
        console.log(result);
      },

    });           


    var styles = StyleSheet.create({
      container: {
        flex: 1,
        backgroundColor: '#F5FCFF',        
      },
      contentContainer: {
        flex: 1,
        alignItems: 'center',
        justifyContent: 'center',
      }
    });

    AppRegistry.registerComponent('MyFirstReactapril', () => cameraApp);
但是我收到了这个错误 未定义不是对象(计算‘this.pros.Navigator.ush’)

我不知道它出了什么问题,请帮帮忙。 或者有没有图书馆可以读取QRCode并给我提供链接或字符串?

推荐答案

NavigatorIOS组件只能在iOS下使用。您需要使用可在Android和iOS中运行的Navigator组件。

这篇关于当QRcode读取库时,未定义不是对象(计算&#39;this.pros.Navigator.Push的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆