uni-app 富文本图片处理(有些带域名,有些不带域名)

这里直接上代码了

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;

猜你喜欢

转载自blog.csdn.net/qq_42543264/article/details/122466761