给小程序的富文本里隐藏的图片添加宽高

第一种方法:接口里给img标签加样式(后台PHP)

$info['contents'] = str_replace("<img ", "<img style='max-width:100%;height:auto;'", $info['contents']);


第二种方法:小程序里给img标签加样式(前端小程序里  推荐!!!

that.setData({
    //富文本内容
    nodes:res.data.data.ginfo.introduce.replace(/\<img/gi, '<img style="max-width:100%;height:auto"'),
})
 

发布了69 篇原创文章 · 获赞 53 · 访问量 19万+

猜你喜欢

转载自blog.csdn.net/sinat_38992528/article/details/100081315