富文本去除标签空格

//富文本去标签
Vue.prototype.$filterHTMLTag = function (str) {
  str = str.replace(/<\/?[^>]*>/g,''); //去除HTML tag
  str = str.replace(/[ | ]*\n/g,'\n'); //去除行尾空白
  str = str.replace(/[ ]|[&nbsp;]/g, '');//去除&nbsp;
  str=str.replace(/ /ig,'');//去掉 
  return str;
}
posted @ 2019-12-09 15:56  蔡徐坤学前端  阅读(1798)  评论(0编辑  收藏  举报