下載完以後咱們須要用到目錄下的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內容了微信小程序