🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## 在v-html指令时如何使用过滤器 ``` // html <div class="word" v-html="$options.filters.filters2(item.news_content)"></div> // script filters: { filters2: function (arg) { arg.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, function (match, capture) { arg = arg.replace(new RegExp(capture, 'g'), baseImgUrl + capture); }); return arg; } } ``` ## 在v-html绑定HTML的内容时,不会继承组件中的样式 ========> 解决方式: 去掉style的作用域scoped