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>
这样修改即可。