vue利用正则去除富文本的标签和样式
const removeHtmlStyle =(html :any)=> {
let relStyle = /style\s*?=\s*?([‘"])[\s\S]*?\1/g;
//去除样式
let relTag = /<.+?>/g;
//去除标签
let relClass = /class\s*?=\s*?([‘"])[\s\S]*?\1/g;
// 清除类名 let newHtml = "";
if (html) {
newHtml = html.replace(relStyle, "");
newHtml = newHtml.replace(relTag, '');
newHtml = newHtml.replace(relClass, '');
}
return newHtml;
};