最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

使用vue和datatables進(jìn)行表格的服務(wù)器端分頁實(shí)例代碼

 更新時(shí)間:2017年06月07日 10:21:08   作者:ronyongxian  
本篇文章主要介紹了使用vue和datatables進(jìn)行表格的服務(wù)器端分頁實(shí)例代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

想法很簡單,用vue生成表格的行,datatables生成分頁信息,不想過程曲折,特此記錄。

datatables端代碼:

$('#dataTables-example').DataTable({ 
      responsive: true, 
      "serverSide" : true,  
      "ajax": function (data, callback, settings) { 
        postJson( 
            "/AccessControlSystem/user/selectByPrimary", 
            {'pageSize':data.length,'pageNo':data.start/data.length+1}, 
            function(result){ 
              callback({'draw':data.draw,'recordsTotal':userCount,'recordsFiltered':userCount,'data':[]}); 
              $("#userList").html(""); 
              getRoleForUser(result.data); 
              rendorUserList(result.data); 
               
            } 
          ); 
      } 
       
    });

vue端代碼:

//用戶列表 
var UserListComponent = Vue.extend({ 
  template:  
  `<tbody id="userList"> 
  <tr v-for="(user, index) in userList" v-bind:class="index%2==0?'odd':'even'"> 
    <td>{{user.name}}</td> 
    <td> 
      <label v-for="role in user.roleList" class="checkbox-inline"> 
      <input type="checkbox" v-bind:value="role.id" disabled v-model="role.checked">{{role.name}} 
      </label> 
    </td> 
    <td>{{user.createTime}}</td> 
    <td class="center"><button type="button" class="btn btn-primary btn-xs" v-on:click="editUser(user.id)">修改</button></td> 
    <td class="center"><button type="button" class="btn btn-primary btn-xs" v-on:click="deleteUser(user.id)">刪除</button></td> 
  </tr> 
  </tbody>`, 
  data: function () { 
    return {'userList':[]}; 
  }, 
  methods: { 
    editUser:function(id){}, 
    deleteUser:function(id){} 
  } 
}); 
 
 
function rendorUserList(userList){ 
  var userListComponent = new UserListComponent(); 
  userListComponent.userList = userList; 
  userListComponent.$mount('#userList');  
} 

重點(diǎn)在rendorUserList函數(shù)中,每次生成表格行不能復(fù)用已有的vue實(shí)例,需要先destroy,再重新生成vue實(shí)例,否則無法正常顯示第1頁后面的頁。

不知為何,希望懂原理的高手告知。

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

相關(guān)文章

最新評論

那曲县| 虞城县| 科技| 抚顺县| 宿迁市| 东乡| 三明市| 金门县| 大足县| 敦化市| 阿拉善右旗| 新宁县| 游戏| 连城县| 安塞县| 连平县| 偏关县| 定州市| 珠海市| 北京市| 黄梅县| 梁平县| 安国市| 庄河市| 瑞丽市| 池州市| 泸溪县| 沁源县| 佛冈县| 随州市| 新龙县| 娄底市| 衡南县| 富锦市| 南华县| 儋州市| 合江县| 淅川县| 武强县| 崇左市| 神池县|