JS 富文本编码、解码
<rich-text :selectable="true" :nodes="decodedText"></rich-text> const encodedText = '<img src="https://zhxkj-1309150347.cos.ap-guangzhou.myqcloud.com/mall/detail/20221229162213_8539.jpg" alt="" /><img src="https://zhxkj-1309150347.cos.ap-guangzhou.myqcloud.com/mall/detail/20221229162223_7062.jpg" alt="" /&g'; const decodedText = encodedText.replace(/</g, '<') .replace(/>/g, '>') .replace(/"/g, '"') .replace(/&/g, '&'); //把拿到的图片自适应 .replace(/\<img/gi, '<img style="width:100%;height:auto" ') .replace(/style="text-wrap: wrap;"/gi, '') console.log(decodedText);
如果rich-text标签导出来的图片有间隙 那么可以:
<rich-text style="font-size:0" :selectable="true" :nodes="productdetail"></rich-text>// 加一个style="font-size:0"

浙公网安备 33010602011771号