根据指定字符串在字符串(想要替换的字符串)中找到并替换
removeFun(description) {
description = description.replace(/<\/?[^>]*>/g, ''); // 去除HTML tag 如果后端返回的数据或者处理的数据不带标签 不用写这一步
————以上都是去除 后端返回的 "<span class="unable-analyse">bad input path</span>" 这种格式————————————————
var reg = new RegExp('(' + description + ')', 'g'); //要替换的
//前面是替换的字符串 后面是新的字符串
var newstr = this.errorsContent.failReason.replace(reg, 替换的字符串this.errorsContent.highLightKey );
console.log(newstr)//替换完成的字符串
如果想要根据替换的字符串来出现高亮的话 可以这样写
this.errorsContent.failReason.replace(reg, `<span class="Highlight">${111}</span>` );
},
样式中
>>>.Highlight{
color:red;
}