过滤后端返回的html文本标签

let escape2Html=(str)=>{
  var arrEntities = { 'lt': '<', 'gt': '>', 'nbsp': ' ', 'amp': '&', 'quot': '"' };
  return str.replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) { return arrEntities[t]; }).replace(/<img/gi, '<img style="max-100%;height:auto;" ');
}

原文地址:https://www.cnblogs.com/fanqiuzhuji/p/12516088.html