欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

layUI實(shí)現(xiàn)列表查詢功能

 更新時(shí)間:2019年07月27日 11:39:35   作者:weixin_40092506  
這篇文章主要為大家詳細(xì)介紹了layUI實(shí)現(xiàn)列表查詢功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

layUI可以直接使用本地的json文件進(jìn)行列表數(shù)據(jù)渲染,但,我們會(huì)發(fā)現(xiàn),官網(wǎng)ctr+c ctr+v 過(guò)來(lái)的代碼在做查詢時(shí)每次看起來(lái)都有列表刷新的動(dòng)作,但實(shí)際操作無(wú)效,百度了一大圈也沒(méi)找到具體的原因,無(wú)奈繼續(xù)回去看官網(wǎng),后面總結(jié)出只有一點(diǎn),也是大家比較容易忽略的一點(diǎn):

官網(wǎng)說(shuō)在查詢時(shí)的url必須設(shè)置異步接口,so,如果我們不借助后臺(tái)看起來(lái)這個(gè)效果好像是單靠前端是出不來(lái),但,為了本地演示,這里寫(xiě)了一個(gè)很low的方法,單靠show()hide()方法來(lái)實(shí)現(xiàn)查詢效果(效果演示可以單不建議實(shí)際開(kāi)發(fā)中使用該方法)

以下代碼粘貼復(fù)制便可直接使用:

<div class="demoTable">
 搜索ID:
 <div class="layui-inline">
 <input class="layui-input" name="id" id="demoReload" autocomplete="off">
 </div>
 <button class="layui-btn" data-type="reload">搜索</button>
</div>

<table class="layui-hide" id="LAY_table_user" lay-filter="user"></table>
<script src="js/layui/layui.js" charset="utf-8"></script>
<script>
 layui.use('table', function(){
 var table = layui.table;
 //方法級(jí)渲染
 var tabins = table.render({
  elem: '#LAY_table_user'
  ,url: 'new_file.json'
  ,cols: [[
  {checkbox: true, fixed: true}
  ,{field:'id', title: 'ID', width:80, sort: true, fixed: true}
  ,{field:'username', title: '用戶名', width:80}
  ,{field:'sex', title: '性別', width:80, sort: true}
  ,{field:'city', title: '城市', width:80}
  ,{field:'sign', title: '簽名'}
  ,{field:'experience', title: '積分', sort: true, width:80}
  ,{field:'score', title: '評(píng)分', sort: true, width:80}
  ,{field:'classify', title: '職業(yè)', width:80}
  ,{field:'wealth', title: '財(cái)富', sort: true, width:135}
  ]]
  ,id: 'testReload'
  ,page: true
  ,height: 315
  ,done:function(res){
  }
 });

 var $ = layui.$, active = {
  reload: function(){
  var demoReload = $('#demoReload');

  //執(zhí)行重載
  table.reload('testReload', {
   page: {
   curr: 1 //重新從第 1 頁(yè)開(kāi)始
   }
   ,where: {
   key: {
    id: demoReload.val()
   }
   }
  });
  }
 };
 $('.demoTable .layui-btn').on('click', function(){
  search = $('#demoReload').val();
  $('.layui-table-fixed tbody tr').each(function(i){
   var id = $(this).children('td').eq(1).children('div').html();
   if(id.indexOf(search)>=0){
   $(this).show()
   $('.layui-table-main tbody tr').eq(i).show()
   }else{
   $('.layui-table-main tbody tr').eq(i).hide()
   $(this).hide();
   }
  });
 });

 });
</script>

</body>
</html>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論