// Filter discoloration

brightenKeyword(val, keyword) {
   val = val + ' ';
   if(val.indexOf(keyword) ! == -1 && keyword ! = =' ') {
        return val.replace(keyword, '<font color="#409EFF">' + keyword + '</font>')}else {
      returnBrightenKeyword (val, keyword) {const Reg = new RegExp(keyword,'i');
    if (val) {
        return val.replace(Reg, `<span style="color: #409EFF;">${keyword}</span>`); }}Copy the code

// How to use it

<el-table-column label="Maintenance Content">
   <template slot-scope="scope">
      <span v-html="brightenKeyword(scope.row.strContent, filters.strContent)" ></span>
   </template>
</el-table-column>
Copy the code

Open Source Project Address:Github.com/alex-0407/v…

Results demonstrate


For more technical articles, video tutorials and open source projects such as Angular1/2/4/5, IONic1/2/4/4, React, Vue, wechat mini programs, NodeJS, etc. Please scan the following QR code to follow wechat public account.


Front end of the most popular framework – small program TWO-DIMENSIONAL code