在微信中点击链接进入网页,分享时无法获取缩略图、描述等信息,生成分享卡片,而扫码进入或者在公众号中进入却可以。
wx.config({
debug: true,
appId: response.data.appId,
timestamp: response.data.timestamp,
nonceStr: response.data.nonceStr,
signature: response.data.signature,
jsApiList: ["updateAppMessageShareData"],
});
wx.ready(function () {
//需在用户可能点击分享按钮前就先调用
wx.updateAppMessageShareData({
title: "服饰公司", // 分享标题
desc: "生产服饰", // 分享描述
link: "https://www.yunweaver.com/demo/test/index.html", // 分享链接,该链接域名或路径必须与当前页面对应的服务号JS安全域名一致
imgUrl: "https://www.yunweaver.com/demo/test/9.jpg", // 分享图标
success: function () {
// 设置成功
alert("微信分享设置成功");
},
fail: function (err) {
alert("微信分享设置失败:" + err.errMsg);
},
});
});
wx.error(function (res) {
console.error("微信分享配置错误:", res);
});
} else {
console.error("获取微信分享配置失败:", response);
}

你好,符合预期