您好,欢迎来到步遥情感网。
搜索
您的当前位置:首页vue2中实现搜索结果中关键词高亮的代码

vue2中实现搜索结果中关键词高亮的代码

来源:步遥情感网


本篇文章给大家带来的内容是关于vue2中实现搜索结果中关键词高亮的代码,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。

// 筛选变色

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技巧

Copyright © 2019- obuygou.com 版权所有 赣ICP备2024042798号-5

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务