You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Navigator.share API 向Pinterest分享时无法附带文本信息

问题:ReactJS中使用navigator.share向Pinterest分享图片无法附带描述信息

我在ReactJS应用里使用navigator.share接口向Pinterest分享图片时,仅能保存图片,无法附带描述信息。桌面端通过URI模式可以实现图片和描述的同时保存,代码如下:

<a 
  data-pin-do="buttonBookmark" 
  data-pin-lang="en"
  href={`https://www.pinterest.com/pin/create/button/?url=${url}&amp;medial=${imageUrl}&amp;description=${desc}`}
/>

但移动端使用相同代码时,仍然只能保存图片。于是我尝试改用navigator.share接口,代码如下:

const handleNativeShare = async ({ title, url, image, text }) => {
  if (typeof window !== undefined) {
    if (typeof navigator !== undefined) {
      if (navigator.share) {
        const blob = await fetch(image).then((response) => response.blob());
        let name=Date.now()+"-"+title+".png"
        let file = new File([blob], name, { 
          type: blob.type, lastModified: Date.now() 
        });

        let shareData = {
          text, 
          url,
          title,
          files: [file],
        };
        navigator.share(shareData)
          .then(() => handleShare())
          .catch((err) => console.log("Error sharing", err));
      } else {
        alert("Share not supported by this browser")
      }
    }
  }
}

结果移动端依旧只能保存图片,描述、标题或URL信息都无法附带,分享界面截图如下:

Pinterest移动端分享界面截图

内容的提问来源于stack exchange,提问作者Nadir Hussain

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 14:02:36