Explorar el Código

完善富文本图片展示

306132416@qq.com hace 4 años
padre
commit
83700bcf45
Se han modificado 1 ficheros con 7 adiciones y 1 borrados
  1. 7 1
      pages/activity/activity_deatil.vue

+ 7 - 1
pages/activity/activity_deatil.vue

@@ -246,6 +246,12 @@ export default {
         },
       });
     },
+	replaceImg(html){
+			  let result = html.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, function (match,capture) {
+					return '<img src=' + getApp().globalData.shareUrl + capture +' style="max-width:100%;height:auto;display:block;margin:10px 0;"/>';
+			  });
+			 return result
+	},
     getRich() {
       uni.request({
         url:
@@ -258,7 +264,7 @@ export default {
 
         success: (res) => {
           if (res.statusCode === 200) {
-            this.textModel.text = res.data;
+           this.textModel.text = this.replaceImg(res.data);
           }
         },
         fail: () => {