第一次記錄Bootstrap table學習筆記(1),bootstrap學習筆記

來源:互聯網
上載者:User

第一次記錄Bootstrap table學習筆記(1),bootstrap學習筆記

第一次使用Bootstrap-table這個表格外掛程式,記錄一下使用過程中遇到的問題。

|引入CSS檔案

<link rel="stylesheet" href="bootstrap.min.css"><link rel="stylesheet" href="bootstrap-table.css"> 

|引入相關庫

我們需要引入Jquery庫、bootstrap庫、以及bootstrap-table.js檔案

<script src="jquery.min.js"></script><script src="bootstrap.min.js"></script><script src="bootstrap-table.js"></script><-- put your locale files after bootstrap-table.js --><script src="bootstrap-table-zh-CN.js"></script>

|啟用Bootstrap Table外掛程式:

官方文檔中給出了我們有兩種那個方式來啟用bootstrap-table外掛程式:

1、通過data屬性的方式:

<table data-toggle="table"> <thead> <tr>  <th>Item ID</th>  <th>Item Name</th>  <th>Item Price</th> </tr> </thead> <tbody> <tr>  <td>1</td>  <td>Item 1</td>  <td>$1</td> </tr> <tr>  <td>2</td>  <td>Item 2</td>  <td>$2</td> </tr> </tbody></table>

2、通過js的方式:

//只需要HTML中寫下table標籤,並設定id<table id="table"></table>
$('#table').bootstrapTable({ columns: [{ field: 'id',     title: 'Item ID' }, { field: 'name', title: 'Item Name' }, { field: 'price', title: 'Item Price' }], data: [{ id: 1, name: 'Item 1', price: '$1' }, { id: 2, name: 'Item 2', price: '$2' }]});

也可以通過url擷取資料

$('#table').bootstrapTable({ url: 'data1.json', columns: [{ field: 'id',    //與傳回值的JSON資料的key值對應 title: 'Item ID'  //列名 }, { field: 'name', title: 'Item Name' }, { field: 'price', title: 'Item Price' }, ]});

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.