在rn 中使用react-native-picker选择器,总结如下。
一、下载
npm install react-native-picker --save react-native link
二、安卓端配置
1.文件./android/settings.gradle中末尾添加
include ':react-native-picker' project(':react-native-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-picker/android')
2.文件./android/app/build.gradle的dependencies内添加(注意其他行有逗号",",最后一行没逗号):
... dependencies { ... compile project(':react-native-picker') } ...
3.文件./android/app/src/main/java/com/xxx/xxx/MainApplication.java中添加:
//插在上面
import com.beefe.picker.PickerViewPackage; ... @Override protected List<ReactPackage> getPackages() { return Arrays.<ReactPackage>asList( new MainReactPackage(), //插入这行 new PickerViewPackage() ); } ...
4.重新运行项目即可
标签:picker,...,react,new,android,native From: https://www.cnblogs.com/sexintercourse/p/16962252.html