我尝试读取QR码与反应本土 然后我安装库不确定是不是(评估“this.props.navigator.push”),而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.props.navigator.push”)
,我不知道是什么不对的地方,请大家帮忙。 或者是否有任何库可以读取QRCode并给我链接或字符串?
嘿,你注册的索引组件,而不是cameraApp,顺便说一句,把儿童组件在顶部是更好 –
@liupluto没有改变,仍然有错误 –