//移除旧的样式 let html = data.goods_desc.replace(/<img[^>]*>/gi, (match, capture)=> { match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, ''); return match; }); //再设置新的样式 html = html.replace(/\<img/gi, '<img style="width:100%;display:inherit;height:auto;text-align:center;"');
标签:style,行内,样式,replace,程序修改,html,gi,文本,match From: https://www.cnblogs.com/lixiaosong/p/17782787.html