这是麻烦:我已经搜索了高低,我不能在我的生活中找到如何在React Native中显示文件选择器对话框.最接近的是图像选择器(第三方组件),但它是一个专门的界面,不允许我从
Android的文件系统中挑选任意文件.
有人知道,我怎么选择文件?
有人知道,我怎么选择文件?
我正在使用这个包
react-native-file-picker
>从github安装包
npm install https://github.com/Lichwa/react-native-file-picker –save
>然后链接它:
rnpm link react-native-file-picker
>导入包
var FilePickerManager = require(‘NativeModules’).FilePickerManager;
>然后像这样使用它:
const options = { title: 'File Picker',chooseFileButtonTitle: 'Choose File...' }; FilePickerManager.showFilePicker(options,(response) => { console.log('Response = ',response); if (response.didCancel) { console.log('User cancelled photo picker'); } else if (response.error) { console.log('ImagePickerManager Error: ',response.error); } else if (response.customButton) { console.log('User tapped custom button: ',response.customButton); } else { this.setState({ file: response }); } });
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。