如何使用阿里云建设网站,华为手机价格大全,海东高端网站建设,招远做网站前端获取到后台数据 不做处理 就会出现下面问题 图片 视频超出视图显示不全 处理
//info 是富文本
view v-ifinfo v-htmlreplaceWhite(info)/view调用下面方法
replaceWhite(html) { // 处理富文本默认图片#xff0c;视频大小let newContent html.replace…前端获取到后台数据 不做处理 就会出现下面问题 图片 视频超出视图显示不全 处理
//info 是富文本
view v-ifinfo v-htmlreplaceWhite(info)/view调用下面方法
replaceWhite(html) { // 处理富文本默认图片视频大小let newContent html.replace(/video[^]*/gi, function(match, capture) {match match.replace(/style[^]/gi, ).replace(/style[^]/gi, );match match.replace(/width[^]/gi, ).replace(/width[^]/gi, );match match.replace(/height[^]/gi, ).replace(/height[^]/gi, );return match;}).replace(/img[^]*/gi, function(match, capture) {match match.replace(/style[^]/gi, ).replace(/style[^]/gi, );match match.replace(/width[^]/gi, ).replace(/width[^]/gi, );match match.replace(/height[^]/gi, ).replace(/height[^]/gi, );return match;});newContent newContent.replace(/style[^]/gi, function(match, capture) {match match.replace(/width:[^;];/gi, max-width:100%;).replace(/width:[^;];/gi,max-width:100%;);return match;});newContent newContent.replace(/br[^]*\//gi, );newContent newContent.replace(/\video/gi,video stylemax-width:100%;height:auto;display:inline-block;margin:10rpx auto;).replace(/\img/gi,img stylemax-width:100%;height:auto;display:inline-block;margin:10rpx auto;);return newContent;},参考大佬 感觉文章好的话记得点个心心和关注和收藏有错的地方麻烦指正一下如果需要转载,请标明出处多谢