1. 程式人生 > >基於Bootstrap的標籤頁元件bootstrap-tab使用說明

基於Bootstrap的標籤頁元件bootstrap-tab使用說明

bootstrap-tab

bootstrap-tab

bootstrap-tab元件是對原生的bootstrap-tab元件的封裝,方便開發者更方便地使用,主要包含以下功能:

  • tab頁初始化
  • 關閉tab頁
  • 新增tab
  • 顯示tab頁
  • 獲取tab頁ID

使用

Step1 :引入樣式

<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="font-awesome/css/font-awesome.min.css">
<!--bootstrap-tab樣式-->
<link rel="stylesheet" href="../css/bootstrap-tab.css">

Step2:引入指令碼

<script src="jquery/jquery-1.8.3.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script src="../js/bootstrap-tab.js"></script>

Step3:使用

<div id="tabContainer"></div
>
<script> $("#tabContainer").tabs({ data: [{ id: 'home', text: '百度一下', url: "tab_first.html", closeable: true }, { id: 'admineap', text: 'AdminEAP', url: "tab_second.html" }, { id: 'edit'
, text: '編輯人員', url: "tab_content.html", closeable: true }], showIndex: 1, loadAll: false }) $("#tabContainer").data("tabs").addTab({id: 'test', text: 'addTab', closeable: true, url: 'tab_content.html'})
</script>

引數和方法說明

引數說明

引數名稱 預設值 可選值 說明
data tab頁資料來源(物件列表),包含id,text,url,closeable屬性
id 必須,單個tab的id
text 必須,單個tab頁的標題
url 必須,單個tab頁的內容url
closeable false true,false 單個tab頁是否可關閉
showIndex 0 預設顯示頁的索引
loadAll true true,false true=一次全部加在頁面,false=只加在showIndex指定的頁面,其他點選時載入,提高響應速度

方法說明

方法名稱 引數 引數說明 方法說明
init tab元件初始化入口方法
builder data tab資料 構建tab頁的主方法
loadData 載入tab頁的內容,根據loadAll即時載入或者點選時載入
addTab obj 單個tab的資料 增加一個tab頁
showTab tabId tab的id 根據id顯示tab頁
getCurrentTabId 獲取當前活動tab頁的ID

相關連結