微信小程序自带的 富文本的解析显示

//js页面(result.data.newdata.content----html标签)
content = result.data.newdata.content.replace(/\<img/gi, '<img style="width:90%!important;height:auto;display:block;margin:0 auto" ')
        .replace(/style\s*?=\s*?([‘"])[\s\S]*?\1/ig, 'style="max-width:100%;height:auto;"')
        .replace(/<section/g, '<div')
        .replace(/\/section>/g, '\div>')


//html页面
 <rich-text nodes="{{content}}"></rich-text>

猜你喜欢

转载自blog.csdn.net/qypingi/article/details/101271369