vue去除富文本的标签和样式
作者:互联网
vue利用正则去除富文本的标签和样式
ts:
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; };template:
<div class="rich" v-html="removeHtmlStyle(teacherData.teacher_intro)"></div>
标签:vue,标签,replace,html,let,newHtml,去除,文本 来源: https://www.cnblogs.com/whqbk/p/16491066.html