【微信小程序遇到的坑】WxParse实现对html标签的解析(html文本在小程序里的展示)

小程序通过WxParse实现对html标签的解析,并且图片可以查看大图


wxParse下载地址https://pan.baidu.com/s/1fl-1HwDgLP1_QXysPitbYg


使用方法:

一:将wxParse引入项目中



二:在需要解析html的js文件中,引入wxParse.js

const WxParse = require('../../../wxParse/wxParse.js');

let total_content = data.introduce //html标签文章
        /**
         * WxParse.wxParse(bindName , type, data, target,imagePadding)
         * 1.bindName绑定的数据名(必填)
         * 2.type可以为html或者md(必填)
         * 3.data为传入的具体数据(必填)
         * 4.target为Page对象,一般为this(必填)
         * 5.imagePadding为当图片自适应是左右的单一padding(默认为0,可选)
         */
        WxParse.wxParse('article', 'html', total_content, that, 5);

三:在wxml文件里,引入wxParse模板

< import src= "../../../wxParse/wxParse.wxml" / >

在需要放置html内容的地方,添加模板

< template is= "wxParse" data= "{{wxParseData:article.nodes}}" / >


即可完成对html标签的解析


猜你喜欢

转载自blog.csdn.net/superkm/article/details/80744039