- 拿到后台返回的富文本内容处理如下:
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