【问题标题】:react native - How to add a prompt option to the user while choosing an app to open the file with?react native - 如何在选择打开文件的应用程序时向用户添加提示选项?
【发布时间】: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


【解决方案1】:

好的,我找到了解决方案。您应该有多个应用程序可以打开您的文件,只有您才能获得提示选项。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-28
    • 1970-01-01
    • 1970-01-01
    • 2018-09-19
    • 1970-01-01
    • 2020-04-17
    • 1970-01-01
    相关资源
    最近更新 更多