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:
-
Img to add a class, specify the style in app.wxss or page.wxss in.
-
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; }