本文以修改富文本中img地址为例
import url from './urls' // imgUrl 图片要修改的url
function changePhoto (data) {
let result = data.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, function (match, capture) {
match = '<img src=' + url.imgUrl + capture + ' title="01.png" alt="01.png" style="max-width:890px" class="cpImg"/>';
return match
});
data = result
return data
}
export default { changePhoto };