简体   繁体   English

如何使用 react-native 创建文件扩展名?

[英]How to create a file extension using react-native?

im building a notebloc with react-native, now im implementing the share section, the problem is that when I select the app that I want share with, I want to share the note with an extension, and not only text, for example like in java when someone saves the data in a .txt, well, thats what Im trying to do in react-native, get the data, save it in a .html document and send it, for now im just using the default example of react:我用 react-native 构建了一个 notebloc,现在我实现了共享部分,问题是当我选择我想与之共享的应用程序时,我想用扩展名共享笔记,而不仅仅是文本,例如java 当有人将数据保存在 .txt 中时,嗯,这就是我尝试在 react-native 中做的事情,获取数据,将其保存在 .html 文档中并发送,现在我只使用默认的 react 示例:

share = async () => {
    try {
        const result = await Share.share({
          message: 'React Native | A framework for building native apps using React',
        });
        
        if (result.action === Share.sharedAction) {
            
            console.log(JSON.parse(result.activityType));
        }
    } catch (error) {
        alert(error.message);
    }
}

so when I select the app that I want to share with it will send 'React Native | A framework for building native apps using React'因此,当我选择要与之共享的应用程序时,它会发送'React Native | A framework for building native apps using React' 'React Native | A framework for building native apps using React' , but I want to send Note.html , how can I do that? 'React Native | A framework for building native apps using React' ,但我想发送Note.html ,我该怎么做?

There is no such thing as an "extension" here because you are not saving a file.这里没有“扩展名”这样的东西,因为您没有保存文件。 According to the documentation :根据文档

Open a dialog to share text content.打开一个对话框以共享文本内容。

So you can only share plain text with Share.share() .因此,您只能使用Share.share()共享纯文本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM