我使用React-native Expo "sdkVersion": "35.0.0"
。现在,我遇到带有相机组件(初始片段)的本机应用程序代码的错误TypeError: undefined is not an object (evaluating '_expo.BarCodeScanner.Constants')
:
import { BarCodeScanner } from 'expo';
import * as FileSystem from 'expo-file-system';
import Constants from 'expo-constants';
import * as Permissions from 'expo-permissions';
import { Camera } from 'expo-camera';
...
如何解决?
答案 0 :(得分:0)
Expo似乎更改了其API。 现在我们需要安装一个单独的依赖项:
npm i --save expo-barcode-scanner
然后为这样的组件独立导入BarCodeScanner
对象:
import { BarCodeScanner } from 'expo-barcode-scanner';
import * as FileSystem from 'expo-file-system';
import Constants from 'expo-constants';
import * as Permissions from 'expo-permissions';
import { Camera } from 'expo-camera';