navigator.share (Web Share api) 分享 React App 文字,不是我放的文字 [英] navigator.share (Web Share api) share React App text, not the text I put

查看:80
本文介绍了navigator.share (Web Share api) 分享 React App 文字,不是我放的文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 React(不是 React Native)并且我正在尝试使用 Web Share Api 通过我的应用程序共享一些文本和一个 url.但是,当我打开任何应用程序进行共享时,它会从我放置的文本更改为来自 React 本地开发的默认文本.

I'm using React (not React Native) and I'm trying to use Web Share Api to share some text and an url through my app. However, when I open any app to share, it changes from the text I've put to a default text from React local development.

是的,我使用的是 HTTPS.是的,我使用的是支持 Web Share Api (Safari 13.0.4) 的浏览器.它确实正确共享,但只是不使用我提供的文本,是的,通用文本:"反应应用本地主机该网站是使用 create-react-app 创建的

Yes, I'm using HTTPS. Yes, I'm in a browser that supports Web Share Api (Safari 13.0.4). It does share correctly, but just not using the text I provided and yes a generic text of: "React App localhost this website was created using create-react-app"

这是我用来分享的功能:

This is the function I use to share:

const handleClick = () => {
    if (navigator.share) {
      navigator
        .share({
          title: "Something",
          text: "Hello, please come visit my website",
          url: "www.website.com.br",
        })
        .then(() => {
          console.log("Successfully shared");
        })
        .catch((error) => {
          console.error("Something went wrong", error);
        });
    }
  };

为什么 React 会覆盖我的共享,我该如何避免?这是它发生的gif

Why is React overriding my share and how can I avoid that? Here's a gif of it happening

推荐答案

这不是 Web Share API 或其实现的问题.Notes 应用程序仅支持 url 属性,并根据 url 的元数据显示示例.

This is not a problem with the Web Share API or its implementation. The Notes application supports only the url attribute, and displays a sample based on the url's metadata.

这篇关于navigator.share (Web Share api) 分享 React App 文字,不是我放的文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆