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

bootstrap-table formatter 使用vue組件的方法

 更新時間:2019年05月09日 09:31:00   作者:Chobits  
Bootstrap table是國人開發(fā)的一款基于 Bootstrap 的 jQuery 表格插件,通過簡單的設(shè)置,就可以擁有強(qiáng)大的單選、多選、排序、分頁,以及編輯、導(dǎo)出、過濾(擴(kuò)展)等等的功能。這篇文章重點(diǎn)給大家介紹bootstrap-table formatter 使用vue組件的方法,感興趣的朋友一起看看

bootstrap-table簡介

1.1、bootstrap table簡介及特征:

         Bootstrap table是國人開發(fā)的一款基于 Bootstrap 的 jQuery 表格插件,通過簡單的設(shè)置,就可以擁有強(qiáng)大的單選、多選、排序、分頁,以及編輯、導(dǎo)出、過濾(擴(kuò)展)等等的功能。目前在github上已經(jīng)有2600多個Star,可見其受歡迎程度。其官方網(wǎng)站地址 為:http://bootstrap-table.wenzhixin.net.cn/。里面可以下載使用所需的JS和CSS文件,以及參考文檔和例子。

•支持 Bootstrap 3 和 Bootstrap 2
•自適應(yīng)界面
•固定表頭
•非常豐富的配置參數(shù)
•直接通過標(biāo)簽使用
•顯示/隱藏列
•顯示/隱藏表頭
•通過 AJAX 獲取 JSON 格式的數(shù)據(jù)
•支持排序
•格式化表格
•支持單選或者多選
•強(qiáng)大的分頁功能
•支持卡片視圖
•支持多語言
•支持插件

下面通過實(shí)例代碼給大家介紹bootstrap-table formatter 使用vue組件的方法,具體代碼如下所示:

import { Subject } from "rxjs";
import Vue from "vue";
export const BtEventHub = new Subject();
const VueComList = [];
let VueComId = 0;
BtEventHub.debounceTime(10)
 .filter(() => VueComList.length > 0)
 .delay(10)
 .subscribe(function() {
  const len = VueComList.length - 1;
  for (let i = len; i >= 0; i--) {
   const item = VueComList[i];
   const dom = document.getElementById(item.name);
   if (dom != null) {
    new Vue(item);
    VueComList.splice(i, 1);
   }
  }
  if (VueComList.length === 0) {
   VueComId = 0;
  }
 });
export function BtAddVueCom(obj: object) {
 const id = `_vue_com_${VueComId++}`;
 VueComList.push({
  el: "#" + id,
  name: id,
  ...obj
 });
 setTimeout(() => {
  BtEventHub.next();
 }, 0);
 return id;
}
window["BtAddVueCom"] = BtAddVueCom;
function ColFormatter1(value, row) {
 const id = window.BtAddVueCom({
  template: '<el-switch v-model="row.IsShow"></el-switch>',
  data: function () {
   return {
    row
   }
  }
 });
 return `<div id="${id}"></div>`;
}

ps:Vue 結(jié)合bootstrap table插件使用

bootstrap Table插件可以很方便的搜索排序,方便快捷,下面是結(jié)合vue的完整的例子。

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Vue Bootstrap Table Demo</title>
  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
  <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css" rel="external nofollow" >
  <link rel="stylesheet" href="../plugins/bootstrap-table-develop/src/bootstrap-table.css" rel="external nofollow" >
</head>
<body class="">
  <div>
    <table class="table table-bordered table-striped" id="tableTest1">
    </table>
  </div>
  <script src="../jQuery/jQuery-2.1.4.min.js"></script>
  <script src="../dist/vue.js"></script>
  <script src="../plugins/bootstrap-table-develop/src/bootstrap-table.js"></script>
  <script src="../plugins/bootstrap-table-develop/src/locale/bootstrap-table-zh-CN.js"></script>
  <script>
  var app7 = new Vue({
    el: '#tableTest1',
    data: {
      //message: [],
      message: [],
      columns: [{
          title: 'Id',
          field: 'id'
        },
        {
          field: 'name',
          title: 'Item Name'
        }, {
          field: 'url',
          title: 'url'
        }, {
          field: 'alex',
          title: 'alex'
        }, {
          field: 'country',
          title: 'country'
        }
      ],
    },
    created() {
      //console.log(this.message)
      this.getData();
      this.intervalGetData();
      //console.log(this.message)
    },
    methods: {
      intervalGetData() {
        setInterval(() => {
          //   $.get("selectBtTable.php?action=init_data_list", data => {
          //   var data = JSON.parse(data);
          //   this.message = data;
          //   $('#tableTest1').bootstrapTable('load', this.message);
          //   //console.log(JSON.parse(data))
          //   console.log("get data")
          // })
          this.getData();
        }, 3000)
      },
      getData() {
        //es6 箭頭函數(shù)的寫法
        //  $.get("selectBtTable.php?action=init_data_list", data => {
        //   var data = JSON.parse(data);
        //   this.message = data;
        //   $('#tableTest1').bootstrapTable('load', this.message);
        //   console.log("init data")
        // })
        var that = this;
        $.get("selectBtTable.php?action=init_data_list", function(data) {
          var data = JSON.parse(data);
          that.message = data;
          $('#tableTest1').bootstrapTable('load', that.message);
          console.log("init data")
        })
      }
    },
    mounted() {
      console.log(this.message + "mounted")
      $('#tableTest1').bootstrapTable({ columns: this.columns, height: 500, search: true });
    }
  })
  </script>
</body>
</html>

     (adsbygoogle = window.adsbygoogle || []).push({}); 

總結(jié)

以上所述是小編給大家介紹的bootstrap-table formatter 使用vue組件的方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!

相關(guān)文章

  • js實(shí)現(xiàn)無限級樹形導(dǎo)航列表效果代碼

    js實(shí)現(xiàn)無限級樹形導(dǎo)航列表效果代碼

    這篇文章主要介紹了js實(shí)現(xiàn)無限級樹形導(dǎo)航列表效果代碼,通過一個封裝的JS類實(shí)現(xiàn)無限樹形導(dǎo)航的效果,非常簡單實(shí)用,需要的朋友可以參考下
    2015-09-09
  • js阻止事件追加的具體實(shí)現(xiàn)

    js阻止事件追加的具體實(shí)現(xiàn)

    可以使用 e.stopPropagation(); e.preventDefault();來阻止事件冒泡,和默認(rèn)事件的執(zhí)行。但不能阻止事件的追加,如要追加,請看下面的實(shí)現(xiàn)方法
    2014-10-10
  • 微信小程序報錯: thirdScriptError的錯誤問題

    微信小程序報錯: thirdScriptError的錯誤問題

    這篇文章主要介紹了微信小程序報錯: thirdScriptError,本文給大家分享解決方法,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-06-06
  • IE 下的只讀 innerHTML

    IE 下的只讀 innerHTML

    可以先使用 DOM 的 createElement 方法創(chuàng)建 tr 和 td,然后對 td 的 innerHTML 進(jìn)行相應(yīng)操作,最后用 appendChild 方法把創(chuàng)建的元素添加到 DOM 樹中。這樣在 IE 下就可以正常運(yùn)行了。
    2009-08-08
  • JavaScript實(shí)現(xiàn)簡單版的留言發(fā)布與刪除

    JavaScript實(shí)現(xiàn)簡單版的留言發(fā)布與刪除

    這篇文章主要介紹了如何通過JavaScript實(shí)現(xiàn)簡單的留言板功能:留言的發(fā)布與刪除。文中的示例代碼講解詳細(xì),感興趣的小伙伴可以學(xué)習(xí)一下
    2022-03-03
  • 利用js對象彈出一個層

    利用js對象彈出一個層

    用js實(shí)現(xiàn)彈出層效果,一般用于代替alert
    2008-03-03
  • TypeScript中正確使用interface和type的方法實(shí)例

    TypeScript中正確使用interface和type的方法實(shí)例

    在ts中定義類型由兩種方式:接口(interface)和類型別名(type alias),interface只能定義對象類型,下面這篇文章主要給大家介紹了關(guān)于TypeScript中正確使用interface和type的相關(guān)資料,需要的朋友可以參考下
    2021-09-09
  • JavaScript調(diào)用客戶端的可執(zhí)行文件(示例代碼)

    JavaScript調(diào)用客戶端的可執(zhí)行文件(示例代碼)

    這篇文章主要是對JavaScript調(diào)用客戶端的可執(zhí)行文件(示例代碼)進(jìn)行了介紹,需要的朋友可以過來參考下,希望對大家有所幫助
    2013-11-11
  • bootstrap動態(tài)調(diào)用select下拉框的實(shí)例代碼

    bootstrap動態(tài)調(diào)用select下拉框的實(shí)例代碼

    今天小編就為大家分享一篇bootstrap動態(tài)調(diào)用select下拉框的實(shí)例代碼,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-08-08
  • JS模擬百度搜索框和選項卡的實(shí)現(xiàn)

    JS模擬百度搜索框和選項卡的實(shí)現(xiàn)

    本文主要介紹了JS模擬百度搜索框和選項卡的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-03-03

最新評論