微信小程序/unapp使用rich-text图片之间存在间隙问题
展示富文本的时候图片过大超出屏幕
解决
this.content=res.data.content.replaceAll('<img','<img style="max-width:100%";height:auto;')
展示富文本的时候图片之间存在缝隙
解决
this.content=res.data.content.replaceAll('<img','<img style="max-width:100%";height:auto;')
if(this.content.indexOf('<p><img')){
console.log("mmmmm")
this.content=this.content.replaceAll('<p><img','<p style="font-size:0px;"><img')
}
展示
最终效果图片居中/图片间隙消失
注意
两个重点:
1.max-width:100%";height:auto;
2.font-size:0
indexOf是为了简便的获取富文本中存在的图片位置(可以按照自己的来)
这个方法不是很简洁,码友可以根据自己的理解简化代码