修改富文本编辑器返回的内容的图片宽高

55 阅读1分钟
res.data.content = res.data.content
       .replace(/<p([\s\w"=\/\.:;]+)((?:(style="[^"]+")))/ig,'<p')
       .replace(/<p>/ig, '<p style="font-size: 15px; line-height: 25px;">')
       .replace(/<img([\s\w"-=\/\.:;]+)((?:(height="[^"]+")))/ig, '<img$1')
       .replace(/<img([\s\w"-=\/\.:;]+)((?:(width="[^"]+")))/ig, '<img$1')
       .replace(/<img([\s\w"-=\/\.:;]+)((?:(style="[^"]+")))/ig, '<img$1')
       .replace(/<img([\s\w"-=\/\.:;]+)((?:(alt="[^"]+")))/ig, '<img$1')
       .replace(/<img([\s\w"-=\/\.:;]+)/ig, '<img style="width: 100%;" $1');