时间:2021-07-01 10:21:17 帮助过:4人阅读
// 筛选变色
brightenKeyword(val, keyword) {
val = val + '';
if (val.indexOf(keyword) !== -1 && keyword !== '') {
return val.replace(keyword, '<font color="#409EFF">' + keyword + '</font>')
} else {
return val
}
}// 使用方法
<el-table-column label="维护内容">
<template slot-scope="scope">
<span v-html="brightenKeyword(scope.row.strContent, filters.strContent)" ></span>
</template>
</el-table-column>开源项目地址: https://github.com/alex-0407/...
相关推荐:
JS的正则replace搜索关键字高亮效果
用JS将搜索的关键字高亮显示实现代码_javascript技巧
以上就是vue2中实现搜索结果中关键词高亮的代码的详细内容,更多请关注Gxl网其它相关文章!