最新国产好看的视频,伊人天堂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)文章

最新評論

探索| 淳化县| 涟源市| 霍州市| 手游| 天峻县| 天峻县| 临武县| 南开区| 东安县| 平果县| 兴海县| 内乡县| 游戏| 兴业县| 德令哈市| 松原市| 靖安县| 黄山市| 遂昌县| 芜湖市| 奎屯市| 根河市| 高陵县| 武胜县| 龙南县| 屏边| 武宁县| 咸阳市| 肥城市| 延津县| 瓦房店市| 富蕴县| 洞口县| 青冈县| 德昌县| 江山市| 贞丰县| 浮梁县| 三河市| 新蔡县|