// 去除标签
setText(html) {
return html.replace(/<(p|div)[^>]*>(<br\/?>| )<\/\1>/gi, '\n')
.replace(/<br\/?>/gi, '\n')
.replace(/<[^>/]+>/g, '')
.replace(/(\n)?<\/([^>]+)>/g, '')
.replace(/\u00a0/g, ' ')
.replace(/ /g, ' ')
.replace(/<img[^>]+src\\s*=\\s*['\"]([^'\"]+)['\"][^>]*>/g, '')
.replace(/<\/?(img|table)[^>]*>/g, "") // 去除图片和表格
.replace(/<\/?(a)[^>]*>/g, "") // 去除a标签
},
传入html,返回html
去除标签
原作者