模拟请求接口
wx
.request({
url
: 'https://api.it120.cc/small4/cms/news/detail',
header
: {
'Content-Type': 'application/json'
},
success
: function(res
) {
const CONTENT = res
.data
.data
.content
.replace(
/\<img/gi,
'<img style="width:100%;height:auto" '
);
}
this.setData({
CONTENT: CONTENT,
});
})
重点代码是:replace( /\<img/gi, '<img style="width:100%;height:auto" ' ); #
页面渲染:
<rich
-text
class="image" nodes
="{{ CONTENT }}"> </rich
-text
>
转载请注明原文地址:https://blackberry.8miu.com/read-4405.html