可参考:https://github.com/M-FE/vue-words-highlight
1、安装
npm install --save vue-words-highlight
2、在main.js 中全局引用
import { highlight } from 'vue-words-highlight';
Vue.use(highlight, {
name: 'highlight',
className: 'red',
style: 'color: red',
caseSensitive: false
})
3、运用
<span v-highlight="{keyword: search, separator: ' '}">{{item.name}}</span>
4、效果