微信小程序中显示html富文本的方法


微信小程序中显示html富文本的方法

使用方法:
git地址:https://github.com/icindy/wxParse

一、下载wxParse文件

二、在要引入的页面的js文件中,引入文件

js文件中

var WxParse = require('../../../weui/wxParse/wxParse.js');

css文件中

@import "../../../weui/wxParse/wxParse.wxss";

页面中

"../../../weui/wxParse/wxParse.wxml" />
三、数据绑定

在page.js文件中绑定数据
如:

onLoad: function (options) {
var that = this;
var detail_content ="
我是HTML代码
"; WxParse.wxParse('detail_content', 'html', detail_content, that, 5); } //注意第一个参数需要与wxml中的一致

四、在page的wxml中引入模板

class="newsDt_wrap">