JS搜索字符串,搜索到的字符串高亮处理(H5、uniapp)

...

//需要展示文字高亮的区域
 



JS部分:

//val   需要进行高亮筛选的字符串文本
//editKeyword  需要高亮的文本

brightenKeyword(val, editKeyword) {
    const Reg = new RegExp(editKeyword);
    if (val) {
        const res = val.replace(Reg, `${editKeyword }`);
        return res;
    }
}

你可能感兴趣的:(javascript,uni-app,开发语言)