How to control applet <img> tag in the adaptive rich-text

Applet implemented string into html, i.e. <rich-text node = "{ {html}}"> </ rich-text> by the rich-text. If the string contains html img tags, and img can not adaptive, how to solve it? ?
  Here is the solution

In two ways:

  1. Img to add a class, specify the style in app.wxss or page.wxss in.

  2. Img style to add

    First, by dividing the data string into json 
     var jsonDa = JSON.stringify (res.data.data.ques) .replace (/ <img / gi, "<img class = 'richImg'style =' width:! Auto important; height: Auto Important; max-height:! 100%; width: 100%; ' "); 
     var = newResData the JSON.parse (jsonDa); 
        the console.log (newResData); // get the data has a tag containing img richImg class 
    this.setData ({ 
        arrList: newResData 
    }) 
    
    
    
    app.wxss 
    Rich-text .richImg { 
      max-width: 100%; 
      max-height: 100%; 
      Vertical-align = left: Middle; 
      height: Auto Important;! 
      width: Auto ! Important; 
    }
    

      

Guess you like

Origin www.cnblogs.com/lvxisha/p/11584444.html