一、v-html的使用:
1、html:
<div v-html="content" />
2、在data中:
content: '<span style="color: red; font-weight: bold">test</span>'
3、效果:
二、关键词高亮显示:
1、html:
<div v-html="content" />
2、在data中:
keyWord: 'keyWord',
content: `test test test ${this.keyWord}`.replace(this.keyWord, `<span style="color: red; font-weight: bold">${this.keyWord}</span>`),
3、效果: