下载完以后咱们须要用到目录下的wxParse文件夹,把他拷贝到咱们的项目目录下 html
下面是具体的使用步骤node
1.在app.wxss全局样式文件中,须要引入wxParse的样式表git
@import "/page/wxParse/wxParse.wxss";
2.在须要加载html内容的页面对应的js文件里引入wxParsegithub
var WxParse = require('../../wxParse/wxParse.js');
3.经过调用WxParse.wxParse方法来设置html内容json
/** * WxParse.wxParse(bindName , type, data, target,imagePadding) * 1.bindName绑定的数据名(必填) * 2.type能够为html或者md(必填) * 3.data为传入的具体数据(必填) * 4.target为Page对象,通常为this(必填) * 5.imagePadding为当图片自适应是左右的单一padding(默认为0,可选) */
Page({ data: { }, onLoad: function () { var that = this; wx.request({ url: '', method: 'POST', data: { 'id':13 }, header: { 'content-type': 'application/json' }, success: function(res) { var article = res.data[0].post; WxParse.wxParse('article', 'html', article, that,5); } }) } })
4.在页面中引用模板小程序
<import src="../../wxParse/wxParse.wxml"/> <template is="wxParse" data="{{wxParseData:article.nodes}}"/>
这样就能够在微信小程序中嵌入html内容了微信小程序