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>
這樣修改即可。