1. 拿到后台返回的富文本内容处理如下:
let temp = res.data

if(!this.isEmpty(temp.content)&&temp.content.includes('/minio-api')){
	temp.content = temp.content.replace(/\/minio-api/g,`${fileServerIp}`)
}
//全局匹配到<img />,然后做替换就行
temp.content = temp.content.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, function (match, p1){
   return `<img src='${p1.includes(fileServerIp)? p1 : 'https://images.weserv.nl/?url=' + p1}' />`
})

this.detail = temp
Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐