admin管理员组文章数量:1336632
here's one of my puted methods:
filtered() {
return this.groups.map(group => {
return group.replace(this.search, '<span class="has-background-primary">' + this.search + '</span>');
})
}
This is supposed to highlight text in a searchbox, but the <
is escaped to <
. What should i do to suppress escaping or how can I do it better?
here's one of my puted methods:
filtered() {
return this.groups.map(group => {
return group.replace(this.search, '<span class="has-background-primary">' + this.search + '</span>');
})
}
This is supposed to highlight text in a searchbox, but the <
is escaped to <
. What should i do to suppress escaping or how can I do it better?
- 1 wha r u trying to do because as it looks from here you can do this with v-if – Reşit Körsu Commented Oct 3, 2018 at 16:09
- I'm trying to highlight searched text. if I have 'mozambik' in the list and 'zam' in searchbox i want to have moZAMbik, where caps letter are highlighted so it should look like: Mo<span class="has-background-primary">zam</span>bik – Zbyszek Kisły Commented Oct 3, 2018 at 16:11
- 1 Might be similar to this. stackoverflow./questions/30877491/vue-display-unescaped-html – Stephen Gilboy Commented Oct 3, 2018 at 16:27
1 Answer
Reset to default 6You're on the right track. The only thing missing is a v-html
at the place where you render your result/list.
<div v-for="item in items" v-html="item">
<!-- if the item now contains raw html it will not be escaped -->
</div>
I've created a small fiddle for demonstration: http://jsfiddle/6bto2nkv/
本文标签: javascriptVue is automatically escaping html charactersStack Overflow
版权声明:本文标题:javascript - Vue is automatically escaping html characters - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742412405a2470047.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论