// 筛选变色
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技巧