这里直接上代码了
res.data.GoodsDetails.goods_detail = res.data.GoodsDetails.goods_detail.replace(/<img[^>]*>/ig, function(match, capture) {
// match 图片路径
let isExist = match.includes('https://'); // 是否包含https://
if(!isExist) { // 不包含
match = match.replace(/(src=")/ig, 'src="https://admin.blys.top');
}
return match
})
this.objectification = res.data.GoodsDetails;