微信小程序解析html,wxParse的使用

项目中有显示后台传过来富文本前端显示的功能,因为微信小程序没有html语法,用了wxParse组件解析HTML

wxParse githubd地址: https://github.com/icindy/wxParse (wxParse的源文件和使用方法

image.png

如果用rich-text,结果就是这样
image.png

前端显示:


image.png

wxParse的应用

1.拷贝 wxParse 文件夹,放在项目文件夹下

image.png

2.引用 wxParse

//在使用的Wxss中引入WxParse.css,可以在app.wxss
@import "/wxParse/wxParse.wxss";
//在使用的js中引入WxParse模块
const WxParse = require('../../wxParse/wxParse.js');
// 在使用的wxml引入模板

//这里data中article为bindName