项目中遇到这样的需求,后端返回的是字符串,在vue用v-html显示,里面有style样式,要去除style 在v-html中使用filters,和平时的不一样,推荐项目的方法,定义一个全局的过滤方法 Vue.prototype.removeHtmlStyle = function (html) { var rel = /style\s*?=\s*?([‘"])[\s\S]*?\1/ var newHtml = '' if (html) { newHtml = html.replace(rel,…