bootstrap table使用入門基本用法,bootstraptable

來源:互聯網
上載者:User

bootstrap table使用入門基本用法,bootstraptable

筆者在查詢bootstrap table資料的時候,看了很多文章,發覺很多文章都寫了關於如何使用bootstrap table的例子,當然最好的例子還是官網。但是對於某部分技術人員來說,入門還是不夠詳細,故有了下列的文章。希望我的文章能給大家帶來協助。

bootstrap-table作為常用的TABLE顯示控制項,會經常出現在各位的項目當中。 

使用步驟如下:

第一步: 下載bootstrap-table需要使用的檔案(包括Css and js檔案)

官方網址   http://bootstrap-table.wenzhixin.net.cn/

下載後解壓後可以看到如下目錄格式

bootstrap-table/
├── dist/
│   ├── extensions/
│   ├── locale/
│   ├── bootstrap-table.min.css
│   └── bootstrap-table.min.js
├── docs/
└── src/
    ├── extensions/
    ├── locale/
    ├── bootstrap-table.css
    └── bootstrap-table.js 

第二步:在html頁面或者其他頁面中添加如下CSS 和JS的標籤

注意:CSS檔案和JS檔案在下載檔案夾中均可以找到

<link rel="stylesheet" href="bootstrap.min.css"><link rel="stylesheet" href="bootstrap-table.css">
<script src="jquery.min.js"></script><script src="bootstrap.min.js"></script><script src="bootstrap-table.js"></script><script src="bootstrap-table-zh-CN.js"></script>

最好的做法,是自己定義好CSS和JS擺放的位置,例如在你根目錄下建立bootstrap-table檔案夾,裡面再分css和js檔案夾,將檔案copy到對應的目錄 

第三步: 放入table 的標籤

<table id="table"></table>

第四步:編寫js代碼

<script >$('#table').bootstrapTable({  url: 'data1.json',  columns: [{    field: 'id',    title: 'Item ID'  }, {    field: 'name',    title: 'Item Name'  }, {    field: 'price',    title: 'Item Price'  }, ]});</script>

第五步:編寫資料來源檔案

該例子是直接使用json檔案來實現資料來源,其實大家可以使用其他程式設計語言,例如php jsp等等來實現json的輸出。

data1.json檔案內容如下

[{id:"1",title:"meetweb"},{id:"2",title:"learn bootstrap table"}]

以上就是本文的全部內容,希望對大家的學習有所協助,也希望大家多多支援幫客之家。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.