当前位置:首页 - 微信小程序

小程序的富文本中图片宽度自适应<rich-text>

栏目:微信小程序 | 阅读:1733次 | 发布日期:2022-07-11 16:07:26

JS部分正则匹配图片

let result = res.data.data.post_content;
const regex = new RegExp('<img', 'gi');
result = result.replace(regex, `<img style="width: 90%;margin:0 auto;"`);
this.setData({
html: result
});

HTML部分

<rich-text class="richtext" nodes="{{html}}"></rich-text>

效果图片

image.png


转载请注明出注:小雷的网站 http://leihx.com/index/news/109.html
我要评论

点击QQ图标登陆后才可以发表评论
查看评论

暂时还没有人评论!
版权信息:@2023-2029 www.leihx.com 网站访问量:5433557人次 互联网ICP备案:黔ICP备15016820号-4