搜索或者推荐内容时候,拿到的数据需要和用户输入的数据对比,把从后台返回的数据中涉及到用户输入的字符给特殊样式,我是利用正则匹配,匹配到的给一个红色。
代码:
const reg = new RegExp(`[${
this.question}]`, 'g') // 匹配规则
const replace
搜索或者推荐内容时候,拿到的数据需要和用户输入的数据对比,把从后台返回的数据中涉及到用户输入的字符给特殊样式,我是利用正则匹配,匹配到的给一个红色。
代码:
const reg = new RegExp(`[${
this.question}]`, 'g') // 匹配规则
const replace