小程序解析html富文本标签

未结帖
0 1745
ajian lucy 2017-05-06
悬赏:5飞吻

在这里提下使用教程


一、首先将插件文件夹复制到项目里面



二、导入文件

首先在xx.wxml导入文件,在文件头写上:

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

然后再wxss导入文件,在文件头写上:

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


三、在页面xx.js里的onLoad()方法里面写上:

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

WxParse.wxParse('article', 'html', article, that,5)

此方法的含义为:

[javascript] view plain copy

  1. var article = '<div>我是HTML代码</div>';  

  2. /** 

  3. * WxParse.wxParse(bindName , type, data, target,imagePadding) 

  4. * 1.bindName绑定的数据名(必填) 

  5. * 2.type可以为html或者md(必填) 

  6. * 3.data为传入的具体数据(必填) 

  7. * 4.target为Page对象,一般为this(必填) 

  8. * 5.imagePadding为当图片自适应是左右的单一padding(默认为0,可选) 

  9. */  

  10. var that = this;  

  11. WxParse.wxParse('article''html', article, that,5);  



四、模板引用:

//这里data中article为bindName
<template is="wxParse" data="{{wxParseData:article.nodes}}"/>


热忱回答0


最近热帖

近期热议

  1. javascript——prototype与__proto 9
  2. Mysql 中出现的Data truncated for column 3
  3. 在nginx中使用x-sendfile的解决方案 3
  4. 高版本jQuery面插件实现Ajax上传图片 1
  5. Thinkphp Socket.class.php 类的使用 1
  6. 使用ionic3创建第一个App 0
  7. ios-oc html5 0
  8. nginx.conf 0
  9. 基于ionic3.4.0的项目搭建 0
  10. php 缩略图 0