Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/418.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ExpoBarCodeScannerModule.scanFromURLAsync引发错误_Javascript_React Native - Fatal编程技术网

Javascript ExpoBarCodeScannerModule.scanFromURLAsync引发错误

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" ) )`: -

我试图在React Native中制作一个扫描仪,它获取一个图像文件,扫描它并返回包含在条形码中的数据。我正在使用Expo SDK的扩展。 当我试图使用它时,它会抛出一个错误。 错误看起来像:

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)
     })
}