微信h5分享图标没有展示

 

图标的尺寸太小,在webpack打包时被压缩成base64格式的,而微信分享的图标不支持这种格式。

解决办法: 1  把图标上传到cdn上,分享的地址写 图标上传后的地址即可,或者通过接口请求图标地址也可以,这种方法也容易更换

2 把图标的大小变大

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是Vue微信H5分享的代码示例: ```javascript export default { data() { return { shareTitle: '分享标题', shareDesc: '分享描述', shareLink: window.location.href, shareImgUrl: '分享图标url' } }, mounted() { this.initWechatShare() }, methods: { initWechatShare() { // 引入微信JS-SDK const wx = require('weixin-js-sdk') const url = window.location.href.split('#')[0] const data = { url } // 向后端请求签名数据 axios.get('/api/wechat/signature', { params: data }).then(res => { if (res.data.code === 0) { const signatureData = res.data.data wx.config({ debug: false, appId: signatureData.appId, timestamp: signatureData.timestamp, nonceStr: signatureData.nonceStr, signature: signatureData.signature, jsApiList: [ 'updateAppMessageShareData', 'updateTimelineShareData' ] }) wx.ready(() => { // 分享到朋友圈 wx.updateTimelineShareData({ title: this.shareTitle, // 分享标题 link: this.shareLink, // 分享链接 imgUrl: this.shareImgUrl, // 分享图标 success() { // 分享成功回调 } }) // 分享给朋友 wx.updateAppMessageShareData({ title: this.shareTitle, // 分享标题 desc: this.shareDesc, // 分享描述 link: this.shareLink, // 分享链接 imgUrl: this.shareImgUrl, // 分享图标 type: '', // 分享类型,music、video或link,不填默认为link dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空 success() { // 分享成功回调 } }) }) } }) } } } ``` 在以上代码中,我们使用 axios 向后端请求签名数据,获取 appId、timestamp、nonceStr 和 signature 等信息,然后使用微信 JS-SDK 进行配置和分享分享到朋友圈使用的接口是 `wx.updateTimelineShareData`,分享给朋友使用的接口是 `wx.updateAppMessageShareData`。 注意,以上代码仅供参考,实际使用需要根据自己的情况进行修改。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值