【发布时间】:2021-09-04 09:37:33
【问题描述】:
我使用 react-native-file-viewer 目录 我想知道如何将选项添加到我的代码中 提示用户选择一个应用程序以使用 .. 打开文件 有人知道怎么做吗?
import FileViewer from 'react-native-file-viewer';
import RNFS from 'react-native-fs';
const file = 'actions-for-db.xls';
// feel free to change main path according to your requirements
const dest = `${RNFS.DocumentDirectoryPath}/${file}`;
RNFS.copyFileAssets(file, dest)
.then(() => {
FileViewer.open(dest)
.then(() => { })
.catch(() => { })
console.log(dest);
})
.then(() => {
// success
console.log('success');
})
.catch(error => {
/* */
console.log('error');
});
【问题讨论】:
-
我只问了关于 react-native-file-viewer 的问题..
标签: javascript typescript react-native