微信小程序之rich-text富文本控制图片大小的问题
发表时间:2020-9-27
发布人:葵宇科技
浏览次数:236
<rich-text nodes="{{newResData}}"></rich-text>
    var jsonDa = JSON.stringify(tempConfig.content_yuekajian09).replace(/<img/gi, "<img class='richImg'style='width:auto!important;height:auto!important;max-height:100%;width:100%;'");
    //遍历得到的数据,给img添加CSS和style
    var newResData = JSON.parse(jsonDa);
    console.log(newResData); //得到的数据含有img标签的都有richImg类
    that.setData({
    	newResData: newResData,
	})
rich-text .richImg{
  max-width: 100%;
  max-height: 100%;
  vertical-align: middle;
  height: auto!important;
  width: auto!important;
}









