const handleRichText = (value) => {
if (!value) {
return '--'
}
// 使用正则表达式匹配所有的img标签
let temp = ''
const imgReg = /<img[^>]*>/g;
const images = value.match(imgReg);
if (images) {
images.forEach(img => {
// 替换原有的img标签为带有样式的标签
const newImg = img.replace(imgReg, `<img style="max-width:100%;height:auto;" src="${img.match(/src="?([^" ]*)"?/)[1]}">`);
// 将处理后的img标签内容替换回原内容中
temp = value.replace(img, newImg);
});
}
return temp
}