最新有个新需求,要异步拼接html并渲染数据,并且我这边是用layui的flow.load(流加载)渲染多个进度条。按官网给出的 element.progress('demo', n+'%'); 就是回显不出来。

 两种解决方法

一。html拼接完之后加上 element.init();

1.代码如下:

layui.use(['element', 'flow'], function () {
var element = layui.element,
flow = layui.flow
;
  
flow.load({
elem: tabId
, isAuto: true
, isLazyimg: true
, done: function (page, next) {
 var initDataList = [];
 //这里是调用后台接口返回数据代码
      var itemHtml = "";
      itemHtml += ' <div class="layui-progress coupon-percent" lay-showpercent="true">';
      itemHtml += ' <div class="layui-progress-bar layui-bg-red" lay-percent="50%"></div>';
      itemHtml += ' </div>';
      initDataList.push(html);
      next(initDataList.join(''), page < 10);
      element.init();
    }
  });
});

二。查看了下layui的进度条渲染原理,发现它只是在 calss 为 layui-progress-bar 的节点加上 width 属性而已,所以我们在拼接html时补上去就可以回显了,如果要显示文字的话就在那个节点把 <span class="layui-progress-text">xx%</span> 这个节点拼接上去。(这里可以不用
添加 element.init(); 也可以回显)

1.代码如下

layui.use(['element', 'flow'], function () {
var element = layui.element,
flow = layui.flow
;
  
flow.load({
elem: tabId
, isAuto: true
, isLazyimg: true
, done: function (page, next) {
 var initDataList = [];
 //这里是调用后台接口返回数据代码
      var itemHtml = "";
      itemHtml += ' <div class="layui-progress coupon-percent" lay-showpercent="true">';
      itemHtml += '                        <div class="layui-progress-bar layui-bg-red" lay-percent="50%" style="width: 50%"><span class="layui-progress-text">50%</span></div>';
      itemHtml += ' </div>';
      initDataList.push(html);
      next(initDataList.join(''), page < 10);
    }
  });
});

效果如图:

拼接html不显示layui进度条解决方法的更多相关文章

  1. 【jQuery】页面顶部显示的进度条效果

    <!Doctype html> <html> <head> <title>页面顶部显示的进度条效果</title> <meta htt ...

  2. python实现显示安装进度条

    一直很好奇那种安装进度条,或者启动程序时候显示的进度条是怎么实现的,学习了python之后,sys模块中有个方法可以实现,代码如下:   1 2 3 4 5 6     import sys,time ...

  3. win7 电脑能上网,但是下面的图标显示红叉的解决方法

    win7 电脑能上网,但是下面的图标显示红叉的解决方法 任务管理器里面结束explorer.exe进程,然后,点击文件,新建任务,输入explorer回车看看

  4. Linux 下shell显示-bash-4.1$不显示用户名路径的解决方法

    Linux CentOS下shell显示-bash-4.1$不显示用户名路径的解决方法   问题描述:   CentOS下新增一个用户,登录进去之后shell脚本的信息如下:     而不是我们经常看 ...

  5. CentOS下shell显示-bash-4.1#不显示用户名路径的解决方法

    CentOS下shell显示-bash-4.1$不显示用户名路径的解决方法 问题描述: CentOS下新增一个用户,登录进去之后shell脚本的信息如下: 而不是我们经常看到的username@hos ...

  6. winform,wpf全屏 还显示任务栏的解决方法

    原文:winform,wpf全屏 还显示任务栏的解决方法 以wpf为例: 全屏代码: this.Topmost = true; this.WindowStyle = System.Windows.Wi ...

  7. (转载)SQL Server2008附加数据库之后显示为只读时解决方法

    SQL Server2008附加数据库之后显示为只读时解决方法 啰嗦的话就不多说了,直入主题吧! 方案一: 碰到这中情况一般是使用的sa账户登录的,只要改为Windows身份验证,再附加数据库即可搞定 ...

  8. WPF:验证登录后关闭登录窗口,显示主窗口的解决方法

    http://www.27ba.com/post/145.html WPF:验证登录后关闭登录窗口,显示主窗口的解决方法 最近想做一个基于Socket的通讯工具,想模仿QQ那样,需要先登录,登录成功后 ...

  9. DELPHI7加载UNICODE编码格式的TXT显示为乱码的解决方法

    DELPHI7的STRING默认是ANSI编码,加载UNICODE编码格式的TXT显示为乱码,解决方法如下: procedure TForm1.Button1Click(Sender: TObject ...

随机推荐

  1. git上传本地项目到gitlab

    <1>输入git config --global user.name "你的用户名" <2>输入git config --global user.email ...

  2. vue学习(十二) 指令v-if v-show 控制页面标签的显示与隐藏

    //html <div id="app"> <input type="button" value="toggle" @cl ...

  3. ~~网络编程(四):socket套接字~~

    进击のpython ***** 网络编程--socket socket的中文意思叫做套接字,socket方法其实也叫套接字方法 我们研究过TCP/UDP协议,但是要是让我们自己搭建,就十分困难了 而这 ...

  4. NACOS安装和配置

    安装包nacos-server-1.1.4.tar.gz 环境 JDK1.8 上传及解压 [root@centos7- ~ ]# mkdir -p /cslc/nacos #通过SFTP将安装包上传至 ...

  5. c++ string类find总结

    c++ string类的find:1.find string s = "My cat's breath smells like cat food."; int a=s.find(& ...

  6. Day03_破解Windows7系统密码&用户与组管理&服务器远程管理

    破解Windows系统密码 一.利用5次shift漏洞破解win7密码 1.1 漏洞 1.在未登录系统时,连续按5次shift键,弹出程序c:\windows\system32\sethc.exe 2 ...

  7. MacOS下JDK8的安装与配置

    微信搜索"艺术行者",关注并回复关键词"jdk8"获取安装包和API文档资料! 一.安装环节 1.打开网页 https://www.oracle.com/jav ...

  8. Python随机数函数

    Python随机数函数: ''' choice(seq) 从序列的元素中随机选出一个元素 randrange ([start,] stop [,step]) 从指定范围内,在指定步长递增的集合中 获取 ...

  9. Python os.tcsetpgrp() 方法

    概述 os.tcsetpgrp() 方法用于设置与终端fd(一个由os.open()返回的打开的文件描述符)关联的进程组为pg.高佣联盟 www.cgewang.com 语法 tcsetpgrp()方 ...

  10. QueryRunner使用总结

    使用JDBC技术是一件繁琐的事情,为了使数据库更加高效,有一种简化jdbc技术的操作--DBUtils.DbUtils(org.apache.commons.dbutils.DbUtils)是Apac ...