微信小程序解析html

时间:2017-11-08 11:49:24   收藏:0   阅读:346


1.下载wxParse:https://github.com/icindy/wxParse并拷贝到项目目录下与pages同级即可
2.在app.wxss全局样式头部引入wxParse.wxss
2.在需要解析html的js头部引入wxParse.js并加载数据,如:
var WxParse = require(‘../../../wxParse/wxParse.js‘);
Page({
onLoad: function (options) {
that.setData({
content: WxParse.wxParse(‘databinding‘, ‘html‘,‘要解析的HTML‘, this, 5),
//参数介绍:WxParse.wxParse(绑定的数据名(必填) ,html或者md(必填), 要解析的数据(必填),Page对象,一般为this(必填),imagePadding为当图片自适应是左右的单一padding(默认为0,可选))
});
}
})
3.在相应wxml显示:
<view class="view1-text">
<template is="wxParse" data="{{wxParseData:databinding.nodes}}"/>  //必须和js绑定数据名一致
</view>

以上为微信小程序解析html

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!