【发布时间】:2021-12-19 17:45:03
【问题描述】:
由于 Google Play,我不得不将我的一个旧项目更新到最新的 expo 版本(确切地说是版本 43.0.0)。这个想法是让应用程序简单地扫描二维码并处理数据。但是,expo-barcode-scanner 只能工作一次,之后我需要关闭并再次打开应用程序才能工作。有没有人遇到过这个问题并且(或)知道如何解决它? 以下是我的代码:
{escaneando ? (
<BarCodeScanner
barCodeTypes={[
BarCodeScanner.Constants.BarCodeType.ean13,
BarCodeScanner.Constants.BarCodeType.ean8,
BarCodeScanner.Constants.BarCodeType.upc_a,
BarCodeScanner.Constants.BarCodeType.upc_e,
]}
onBarCodeScanned={this.handleBarCode.bind(this)}
style={[StyleSheet.absoluteFillObject, styles.barscan]}
/>
) : null}
及库规范:
"@react-native-community/masked-view": "^0.1.11",
"@react-native-community/netinfo": "^6.0.5",
"@react-navigation/native": "^6.0.6",
"@react-navigation/stack": "^6.0.11",
"expo": "~43.0.0",
"expo-av": "^10.1.3",
"expo-barcode-scanner": "^11.1.2",
"expo-status-bar": "~1.1.0",
"lodash": "^4.17.21",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "^0.64.2",
"react-native-dropdownalert": "^4.3.0",
"react-native-elements": "^3.4.2",
"react-native-gesture-handler": "^1.10.3",
"react-native-in-app-notification": "^3.2.0",
"react-native-offline": "^6.0.0",
"react-native-paper": "^4.10.0",
"react-native-reanimated": "^2.2.3",
"react-native-safe-area-context": "^3.3.2",
"react-native-screens": "^3.9.0",
"react-native-web": "0.17.1",
"react-navigation": "^4.4.4",
"react-redux": "^7.2.6",
"redux": "^4.1.2",
"redux-thunk": "^2.4.0",
"reselect": "^4.1.2"
【问题讨论】:
-
您也可以使用
expo-camera代替expo-barcode-scanner。expo-camera没有这个问题。它还提供更多选项,例如手电筒/手电筒和切换相机。
标签: react-native expo