uniapp踩坑問題記錄:iOS微信分享圖片不顯示安卓分享正常、Do not nest other components in the text component提示問題


1、iOS微信分享圖片不顯示安裝分享正常

  使用 uni.share() 分享圖文時,安卓手機的縮略圖是可以正常顯示的,但是 iOS 的不顯示。

  問題原因:看官網文檔有介紹,圖片地址建議需小於 20K;所以估計安卓平台沒有限制死,而 iOS 平台估計限制比較死,所以不顯示。

  解決方案:壓縮圖片是其小於 20K。增加壓縮之后 iOS 分享圖片就正常顯示了。

  在封裝的分享方法上統一增加壓縮。

export function shareWx (info) { const channels = getShareChannels() uni.showActionSheet({ itemList: channels.map(channel => { return channel.text }), success: (result) => { const tapIndex = result.tapIndex; let _config = { provider: 'weixin', type: 0, scene: tapIndex === 0 ? 'WXSceneSession' : 'WXSenceTimeline' } if(info.imageUrl) info.imageUrl += '?x-oss-process=image/resize,w_100' Object.assign(_config, info) uni.share(_config) } }) }

2、Do not nest other components in the text component

  有時候在控制台會打印一些提示信息如下:Do not nest other components in the text component, as there may be display differences on different platforms. at view.umd.min.js:1

  翻譯如下:不要在文本組件中嵌套其他組件,因為在不同的平台上可能會有顯示差異。在view.umd.min.js:1

  也就是說不建議在 text 組件中再使用組件,那么我們就要找一下哪里在 text 組件里嵌套使用了別的組件

// 原寫法
<text class="mr15 inl-block">作者:{{task.author}}<vipRole :vip="task.vipRole"></vipRole></text>

// 修改之后
<view class="mr15 inl-block">作者:{{task.author}}<vipRole :vip="task.vipRole"></vipRole></view>

  這樣修改即可。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM