zoukankan      html  css  js  c++  java
  • 微信小程序 富文本插件 循环渲染方式

    感谢GitHub

    https://github.com/icindy/wxParse/wiki/wxParse%E5%A4%9A%E6%95%B0%E6%8D%AE%E5%BE%AA%E7%8E%AF%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95

    介绍

    介绍如何使用wxParse在回复等多条HTML共同渲染的方法

    方法介绍

    /**
    * WxParse.wxParseTemArray(temArrayName,bindNameReg,total,that)
    * 1.temArrayName: 为你调用时的数组名称
    * 3.bindNameReg为循环的共同体 如绑定为reply1,reply2...则bindNameReg = 'reply'
    * 3.total为reply的个数
    */
    var that = this;
    WxParse.wxParseTemArray("replyTemArray",'reply', replyArr.length, that)
    

    使用方式

    • 循环绑定数据
    var replyHtml0 = `<div style="margin-top:10px;height:50px;">
    		<p class="reply">
    			wxParse回复0:不错,喜欢[03][04]
    		</p>	
    	</div>`;
        var replyHtml1 = `<div style="margin-top:10px;height:50px;">
    		<p class="reply">
    			wxParse回复1:不错,喜欢[03][04]
    		</p>	
    	</div>`;
        var replyHtml2 = `<div style="margin-top:10px;height:50px;">
    		<p class="reply">
    			wxParse回复2:不错,喜欢[05][07]
    		</p>	
    	</div>`;
        var replyHtml3 = `<div style="margin-top:10px;height:50px;">
    		<p class="reply">
    			wxParse回复3:不错,喜欢[06][08]
    		</p>	
    	</div>`;
        var replyHtml4 = `<div style="margin-top:10px; height:50px;">
    		<p class="reply">
    			wxParse回复4:不错,喜欢[09][08]
    		</p>	
    	</div>`;
        var replyHtml5 = `<div style="margin-top:10px;height:50px;">
    		<p class="reply">
    			wxParse回复5:不错,喜欢[07][08]
    		</p>	
    	</div>`;
        var replyArr = [];
        replyArr.push(replyHtml0);
        replyArr.push(replyHtml1);
        replyArr.push(replyHtml2);
        replyArr.push(replyHtml3);
        replyArr.push(replyHtml4);
        replyArr.push(replyHtml5);
    
    
        for (let i = 0; i < replyArr.length; i++) {
          WxParse.wxParse('reply' + i, 'html', replyArr[i], that);
          if (i === replyArr.length - 1) {
            WxParse.wxParseTemArray("replyTemArray",'reply', replyArr.length, that)
          }
        }
    
    • 模版使用
       <block wx:for="{{replyTemArray}}" wx:key="">
            回复{{index}}:<template is="wxParse" data="{{wxParseData:item}}"/>
        </block>
    
  • 相关阅读:
    从自然数到有理数
    付费版乐影音下载器使用方法
    Avtiviti之流程变量
    activity(工作流)初步学习记录
    IntelliJ IDEA安装Activiti插件并使用
    golang 性能测试
    Golang性能测试工具PProf应用详解
    java连接ZK的基本操作
    会员体系、积分、等级
    Flink基本概念
  • 原文地址:https://www.cnblogs.com/zonglonglong/p/9212241.html
Copyright © 2011-2022 走看看