Javascript ExpoBarCodeScannerModule.scanFromURLAsync引发错误
我试图在React Native中制作一个扫描仪,它获取一个图像文件,扫描它并返回包含在条形码中的数据。我正在使用Expo SDK的扩展。 当我试图使用它时,它会抛出一个错误。 错误看起来像:Javascript ExpoBarCodeScannerModule.scanFromURLAsync引发错误,javascript,react-native,Javascript,React Native,我试图在React Native中制作一个扫描仪,它获取一个图像文件,扫描它并返回包含在条形码中的数据。我正在使用Expo SDK的扩展。 当我试图使用它时,它会抛出一个错误。 错误看起来像: An exception was thrown while calling `ExpoBarCodeScannerModule.scanFromURLAsync` with arguments `( 1, ( "org.iso.QRCode" ) )`: -
An exception was thrown while calling `ExpoBarCodeScannerModule.scanFromURLAsync` with arguments `(
1,
(
"org.iso.QRCode"
)
)`: -[__NSCFNumber length]: unrecognized selector sent to instance 0xe17787ebcc27c1d0
- node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:104:55 in <unknown>
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:414:4 in __invokeCallback
- ... 4 more stack frames from framework internals
你知道这是什么意思吗?这意味着条形码扫描仪不接受.jpg文件。你应该提供条形码扫描仪的url。这意味着条形码扫描仪不接受.jpg文件。您应该提供条形码扫描仪的url。看看这个。
file = require('./assets/image.jpg');
componentDidMount(){
BarCodeScanner.scanFromURLAsync(this. file).then(data => {
console.log(data)
}).catch(err => {
console.log(err)
})
}