研究這個(gè)我一直研究了倆天,查資料,百度,頭都大了:但是終于搞出來(lái)了:
1首先需要向工程中引入第三方的組件:react-native-barcodescanner
npm install react-native-barcodescanner --save
2.在你的android/settings.gradle下面加上:
include':react-native-barcodescanner',
project(':react-native-barcodescanner').projectDir=newFile(rootProject.projectDir,'../node_modules/react-native-barcodescanner/android')
3.在你的android/app/build.gradle加上這個(gè)依賴(lài)
dependencies{...? ?
?compile project(':react-native-barcodescanner')
}
4. 在你的MainApplication.java文件中加入:
開(kāi)頭:加上? import com.eguma.barcodescanner.BarcodeScannerPackage;
然后在這個(gè):?ListgetPackages() 方法中加上
newBarcodeScannerPackage() ?
5.上代碼:


下面就是掃描成功調(diào)用的方法:


最后的大致顯示效果:因?yàn)槲腋膭?dòng)了一些屬性和組件;
