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

使用ReactJS生成邮件二维码遇Google Lens解析异常的解决方法

解决方案

1. 修正链接格式,移除HTML实体转义

你之前用&(HTML实体)代替&,会导致二维码内容实际存储的是&而非&,Google Lens解析时容易误判链接类型。直接用原始的&拼接参数即可:

const email = "your-email@example.com";
const subject = "Your Subject";
const body = "Email body content";
const mailtoValue = `mailto:${email}?subject=${subject}&body=${body}`;

// 传给react-qr-code组件
<QRCode value={mailtoValue} />

2. 对整个mailto链接进行URL编码

如果上述方法无效,用encodeURIComponent对整个mailto链接编码,确保特殊字符被正确转义,避免Google Lens误识别为HTTP链接:

const mailtoValue = encodeURIComponent(`mailto:${email}?subject=${subject}&body=${body}`);

// 传给react-qr-code组件
<QRCode value={mailtoValue} />

编码后的链接会被扫码工具正确解码为原始mailto格式,不会被强制添加https前缀。

3. 验证二维码内容

生成二维码后,先用手机自带扫码工具(如苹果相机、微信扫码)扫描,确认内容是纯mailto:xxx格式。如果其他工具能正常识别,说明是Google Lens的识别逻辑问题,可建议用户换用其他扫码工具,或在二维码旁标注“使用非Google Lens工具扫码打开邮件”。

内容的提问来源于stack exchange,提问作者Manvitha Vemulapalli

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.30 00:52:03