第一次記錄Bootstrap table學習筆記(1)
第一次使用Bootstrap-table這個表格插件,記錄一下使用過程中遇到的問題。
|引入CSS文件
<link rel="stylesheet" href="bootstrap.min.css"> <link rel="stylesheet" href="bootstrap-table.css">
|引入相關(guān)庫
我們需要引入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標簽,并設(shè)置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獲取數(shù)據(jù)
$('#table').bootstrapTable({ url: 'data1.json', columns: [{ field: 'id', //與返回值的JSON數(shù)據(jù)的key值對應(yīng) title: 'Item ID' //列名 }, { field: 'name', title: 'Item Name' }, { field: 'price', title: 'Item Price' }, ] });
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
基于BootStrap Metronic開發(fā)框架經(jīng)驗小結(jié)【二】列表分頁處理和插件JSTree的使用
本文給大家介紹基于BootStrap Metronic開發(fā)框架經(jīng)驗小結(jié)【二】列表分頁處理和插件JSTree的使用,介紹頁面內(nèi)容常用到的數(shù)據(jù)分頁處理,以及Bootstrap插件JSTree的使用,非常具有參考借鑒價值,感興趣的朋友一起學習吧2016-05-05js動態(tài)修改input輸入框的type屬性(實現(xiàn)方法解析)
本文是對js動態(tài)修改input輸入框的type屬性的實現(xiàn)方法。進行了詳細的介紹,需要的朋友可以過來參考下,希望對大家有所幫助2013-11-11微信小程序首頁的分類功能和搜索功能的實現(xiàn)思路及代碼詳解
這篇文章主要介紹了微信小程序首頁的分類功能和搜索功能的實現(xiàn)思路及代碼詳解,微信宣布了微信小程序開發(fā)者工具新增“云開發(fā)”功能,現(xiàn)在無需服務(wù)器即可實現(xiàn)小程序的快速迭代,感興趣的朋友跟隨小編一起看看吧2018-09-09使用微信小程序API,調(diào)用微信的各種內(nèi)置能力。
微信小程序如何使用小程序API,去調(diào)用微信提供的各種內(nèi)置能力(即微信API)。小程序開發(fā)框架提供豐富的微信原生API,可以方便的調(diào)起微信提供的能力,如獲取用戶信息,本地存儲,支付功能等。2022-12-12