undefined is not an object (evaluating #39;this.props.navigator.push#39;) while QRcode reading library(当QRcode读取库时,未定义不是对象(计算#39;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读取库时,未定义不是对象(计算';this.pros.Navigator.Push的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!