我有一个 react-native 应用程序,我在其中使用 react-native-qrcode-scanner 开发了扫描仪功能。但是,当我尝试扫描数据时,出现以下错误-
error: can't find variable navigation
我在授权令牌行的 onSuccess 方法中看到了这个错误。我的代码-
import React, { Component } from 'react';
import {
Text,
View,
Image,
TouchableOpacity,
Linking
} from 'react-native';
import styles from '../assets/style';
import QRCodeScanner from 'react-native-qrcode-scanner';
export default class ScanScreen extends Component {
onSuccess(scanEvent) {
this.props.navigation.navigate("Result", {
'accessKey': scanEvent.data,
'authorizationToken':navigation.getParam('authorizationToken', undefined),
"userData": navigation.getParam('userData', undefined),
"methodName": "fetchData"
});
}
render() {
return (
<View style={styles.container}>
<QRCodeScanner
onRead={this.onSuccess.bind(this)}
/>
</View>
);
}
}
知道我在这里缺少什么。非常感谢任何帮助。在此先感谢。