Iqembu lohlu
Amaqembu ohlu ayingxenye eguqukayo nenamandla yokubonisa uchungechunge lokuqukethwe. Ziguqule futhi uzinwebe ukuze zisekele cishe noma yikuphi okuqukethwe ngaphakathi.
Isibonelo esiyisisekelo
Iqembu lohlu oluyisisekelo wuhlu olunga-odwe olunezinto zohlu kanye namakilasi afanele. Yakhela phezu kwayo ngezinketho ezilandelayo, noma nge-CSS yakho njengoba kudingeka.
- Into
- Into yesibili
- Into yesithathu
- Into yesine
- Neyesihlanu
<ul class="list-group">
<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
<li class="list-group-item">A fourth item</li>
<li class="list-group-item">And a fifth one</li>
</ul>
Izinto ezisebenzayo
Engeza .active
ku-a .list-group-item
ukukhombisa ukukhetha okusebenzayo kwamanje.
- Into esebenzayo
- Into yesibili
- Into yesithathu
- Into yesine
- Neyesihlanu
<ul class="list-group">
<li class="list-group-item active" aria-current="true">An active item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
<li class="list-group-item">A fourth item</li>
<li class="list-group-item">And a fifth one</li>
</ul>
Izinto ezikhutshaziwe
Engeza .disabled
ku-a .list-group-item
ukuze ukwenze kubonakale kuvaliwe. Qaphela ukuthi ezinye izinto ezinazo .disabled
zizodinga i-JavaScript yangokwezifiso ukukhubaza ngokugcwele imicimbi yazo yokuchofoza (isb, izixhumanisi).
- Into ekhutshaziwe
- Into yesibili
- Into yesithathu
- Into yesine
- Neyesihlanu
<ul class="list-group">
<li class="list-group-item disabled" aria-disabled="true">A disabled item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
<li class="list-group-item">A fourth item</li>
<li class="list-group-item">And a fifth one</li>
</ul>
Izixhumanisi nezinkinobho
Sebenzisa u <a>
-s noma <button>
u-s ukuze udale izinto zeqembu ezisebenzisekayo ezinezimo ezihambisa phezulu, ezikhutshaziwe, nezisebenzayo ngokwengeza okuthi .list-group-item-action
. Sihlukanisa lezi zigaba-mbumbulu ukuze siqinisekise ukuthi amaqembu ohlu enziwe ngezinto ezingasebenzisani (njengama- <li>
s noma <div>
s) awanikezi ngokuchofoza noma ukuthepha ukukhokhela.
Qiniseka ukuthi awusebenzisi .btn
amakilasi ajwayelekile lapha .
<div class="list-group">
<a href="#" class="list-group-item list-group-item-action active" aria-current="true">
The current link item
</a>
<a href="#" class="list-group-item list-group-item-action">A second link item</a>
<a href="#" class="list-group-item list-group-item-action">A third link item</a>
<a href="#" class="list-group-item list-group-item-action">A fourth link item</a>
<a class="list-group-item list-group-item-action disabled">A disabled link item</a>
</div>
Nge <button>
-s, ungakwazi futhi ukusebenzisa disabled
isibaluli esikhundleni .disabled
sekilasi. Ngokudabukisayo, i- <a>
s ayisekeli isici sokukhubazeka.
<div class="list-group">
<button type="button" class="list-group-item list-group-item-action active" aria-current="true">
The current button
</button>
<button type="button" class="list-group-item list-group-item-action">A second button item</button>
<button type="button" class="list-group-item list-group-item-action">A third button item</button>
<button type="button" class="list-group-item list-group-item-action">A fourth button item</button>
<button type="button" class="list-group-item list-group-item-action" disabled>A disabled button item</button>
</div>
Flush
Engeza .list-group-flush
ukuze ususe eminye imingcele namakhona ayindilinga ukuze unikeze uhlu lwezinto zeqembu emaphethelweni esiqukathi esingumzali (isb, amakhadi).
- Into
- Into yesibili
- Into yesithathu
- Into yesine
- Neyesihlanu
<ul class="list-group list-group-flush">
<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
<li class="list-group-item">A fourth item</li>
<li class="list-group-item">And a fifth one</li>
</ul>
Izinombolo
Engeza .list-group-numbered
ikilasi lesilungisi (futhi ngokuzikhethela usebenzise i- <ol>
elementi) ukuze ungene ezintweni zeqembu ezinezinombolo. Izinombolo zenziwa nge-CSS (ngokungafani <ol>
nesitayela sesiphequluli esizenzakalelayo) ukuze kubekwe kangcono phakathi kwezinto zeqembu nokuvumela ukwenziwa ngendlela oyifisayo kangcono.
Izinombolo zenziwa ngokuthi counter-reset
ku- <ol>
, bese zenziwa isitayela futhi zibekwe ne- ::before
pseudo-elementi ku- <li>
no counter-increment
kanye content
.
- Into yohlu
- Into yohlu
- Into yohlu
<ol class="list-group list-group-numbered">
<li class="list-group-item">A list item</li>
<li class="list-group-item">A list item</li>
<li class="list-group-item">A list item</li>
</ol>
Lezi zisebenza kahle ngokuqukethwe ngokwezifiso futhi.
-
IsihlokwanaOkuqukethwe kwento yohlu
-
IsihlokwanaOkuqukethwe kwento yohlu
-
IsihlokwanaOkuqukethwe kwento yohlu
<ol class="list-group list-group-numbered">
<li class="list-group-item d-flex justify-content-between align-items-start">
<div class="ms-2 me-auto">
<div class="fw-bold">Subheading</div>
Content for list item
</div>
<span class="badge bg-primary rounded-pill">14</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-start">
<div class="ms-2 me-auto">
<div class="fw-bold">Subheading</div>
Content for list item
</div>
<span class="badge bg-primary rounded-pill">14</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-start">
<div class="ms-2 me-auto">
<div class="fw-bold">Subheading</div>
Content for list item
</div>
<span class="badge bg-primary rounded-pill">14</span>
</li>
</ol>
Evundlile
Engeza .list-group-horizontal
ukuze ushintshe ukwakheka kwezinto zeqembu zohlu ukusuka kokuqondile kuye kokuvundlile kuwo wonke ama-breakpoint. Noma, khetha okuhlukile okusabelayo .list-group-horizontal-{sm|md|lg|xl|xxl}
ukuze wenze iqembu lohlu livundlile liqala kuleyo breakpoint's min-width
. Okwamanje amaqembu ohlu oluvundlile awakwazi ukuhlanganiswa namaqembu ohlu lwe-flush.
I-ProTip: Ufuna izinto zeqembu ezinobubanzi obulinganayo uma uvundlile? Engeza .flex-fill
entweni ngayinye yohlu yohlu.
- Into
- Into yesibili
- Into yesithathu
- Into
- Into yesibili
- Into yesithathu
- Into
- Into yesibili
- Into yesithathu
- Into
- Into yesibili
- Into yesithathu
- Into
- Into yesibili
- Into yesithathu
- Into
- Into yesibili
- Into yesithathu
<ul class="list-group list-group-horizontal">
<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
</ul>
<ul class="list-group list-group-horizontal-sm">
<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
</ul>
<ul class="list-group list-group-horizontal-md">
<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
</ul>
<ul class="list-group list-group-horizontal-lg">
<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
</ul>
<ul class="list-group list-group-horizontal-xl">
<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
</ul>
<ul class="list-group list-group-horizontal-xxl">
<li class="list-group-item">An item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
</ul>
Amakilasi omongo
Sebenzisa amakilasi anomongo ukwenza izinto zohlu lwesitayela ezinengemuva elihle nombala.
- Into yeqembu yohlu oluzenzakalelayo olula
- Into yeqembu elula eyinhloko
- Into yeqembu yohlu lwesibili olula
- Into yeqembu elula yohlu lwempumelelo
- Into yeqembu elula yohlu lwengozi
- Into yeqembu elula yohlu lwesixwayiso
- Into yeqembu yolwazi olula
- Into yeqembu elula yohlu olukhanyayo
- Into yeqembu elula yohlu olumnyama
<ul class="list-group">
<li class="list-group-item">A simple default list group item</li>
<li class="list-group-item list-group-item-primary">A simple primary list group item</li>
<li class="list-group-item list-group-item-secondary">A simple secondary list group item</li>
<li class="list-group-item list-group-item-success">A simple success list group item</li>
<li class="list-group-item list-group-item-danger">A simple danger list group item</li>
<li class="list-group-item list-group-item-warning">A simple warning list group item</li>
<li class="list-group-item list-group-item-info">A simple info list group item</li>
<li class="list-group-item list-group-item-light">A simple light list group item</li>
<li class="list-group-item list-group-item-dark">A simple dark list group item</li>
</ul>
Amakilasi omongo nawo asebenza .list-group-item-action
. Qaphela ukungezwa kwezitayela zokuhambisa phezulu lapha akukho esibonelweni sangaphambilini. Okunye okusekelwa .active
umbuso; sebenzisa ukuze ubonise okukhethiwe okusebenzayo entweni yohlu lokuqukethwe.
<div class="list-group">
<a href="#" class="list-group-item list-group-item-action">A simple default list group item</a>
<a href="#" class="list-group-item list-group-item-action list-group-item-primary">A simple primary list group item</a>
<a href="#" class="list-group-item list-group-item-action list-group-item-secondary">A simple secondary list group item</a>
<a href="#" class="list-group-item list-group-item-action list-group-item-success">A simple success list group item</a>
<a href="#" class="list-group-item list-group-item-action list-group-item-danger">A simple danger list group item</a>
<a href="#" class="list-group-item list-group-item-action list-group-item-warning">A simple warning list group item</a>
<a href="#" class="list-group-item list-group-item-action list-group-item-info">A simple info list group item</a>
<a href="#" class="list-group-item list-group-item-action list-group-item-light">A simple light list group item</a>
<a href="#" class="list-group-item list-group-item-action list-group-item-dark">A simple dark list group item</a>
</div>
Ukudlulisa incazelo kubuchwepheshe obusizayo
Ukusebenzisa umbala ukwengeza incazelo kunikeza kuphela inkomba ebonakalayo, engeke idluliselwe kubasebenzisi bobuchwepheshe obusizayo - njengezifundi zesikrini. Qinisekisa ukuthi ulwazi olushiwo umbala lusobala kokuqukethwe ngokwako (isb umbhalo obonakalayo), noma lufakwe ngezinye izindlela, njengombhalo owengeziwe ofihliwe .visually-hidden
nekilasi.
Ngamabheji
Engeza amabheji kunoma iyiphi into yeqembu lohlu ukuze ubonise izibalo ezingafundiwe, umsebenzi, nokunye ngosizo lwezinye izinsiza .
- Into yohlu14
- Into yohlu lwesibili2
- Into yohlu lwesithathu1
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between align-items-center">
A list item
<span class="badge bg-primary rounded-pill">14</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
A second list item
<span class="badge bg-primary rounded-pill">2</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
A third list item
<span class="badge bg-primary rounded-pill">1</span>
</li>
</ul>
Okuqukethwe ngokwezifiso
Engeza cishe noma iyiphi i-HTML ngaphakathi, ngisho nasemaqenjini ohlu axhumene njengaleli elingezansi, ngosizo lwezinsiza ze- flexbox .
Faka kuhlu isihloko sento yeqembu
3 izinsuku ezedluleOkunye okuqukethwe kwesimeli endimeni.
Nokunye ukuphrinta okuncane.Faka kuhlu isihloko sento yeqembu
3 izinsuku ezedluleOkunye okuqukethwe kwesimeli endimeni.
Futhi okunye kuthulisiwe ukuphrinta okuncane.Faka kuhlu isihloko sento yeqembu
3 izinsuku ezedluleOkunye okuqukethwe kwesimeli endimeni.
Futhi okunye kuthulisiwe ukuphrinta okuncane.<div class="list-group">
<a href="#" class="list-group-item list-group-item-action active" aria-current="true">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">List group item heading</h5>
<small>3 days ago</small>
</div>
<p class="mb-1">Some placeholder content in a paragraph.</p>
<small>And some small print.</small>
</a>
<a href="#" class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">List group item heading</h5>
<small class="text-muted">3 days ago</small>
</div>
<p class="mb-1">Some placeholder content in a paragraph.</p>
<small class="text-muted">And some muted small print.</small>
</a>
<a href="#" class="list-group-item list-group-item-action">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">List group item heading</h5>
<small class="text-muted">3 days ago</small>
</div>
<p class="mb-1">Some placeholder content in a paragraph.</p>
<small class="text-muted">And some muted small print.</small>
</a>
</div>
Amabhokisi okuhlola namarediyo
Beka amabhokisi okuhlola e-Bootstrap namarediyo phakathi kwezinto zeqembu futhi wenze ngendlela oyifisayo njengoba kudingeka. Ungazisebenzisa ngaphandle <label>
kuka-s, kodwa sicela ukhumbule ukufaka aria-label
isibaluli kanye nenani lokufinyeleleka.
<ul class="list-group">
<li class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value="" id="firstCheckbox">
<label class="form-check-label" for="firstCheckbox">First checkbox</label>
</li>
<li class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value="" id="secondCheckbox">
<label class="form-check-label" for="secondCheckbox">Second checkbox</label>
</li>
<li class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value="" id="thirdCheckbox">
<label class="form-check-label" for="thirdCheckbox">Third checkbox</label>
</li>
</ul>
<ul class="list-group">
<li class="list-group-item">
<input class="form-check-input me-1" type="radio" name="listGroupRadio" value="" id="firstRadio" checked>
<label class="form-check-label" for="firstRadio">First radio</label>
</li>
<li class="list-group-item">
<input class="form-check-input me-1" type="radio" name="listGroupRadio" value="" id="secondRadio">
<label class="form-check-label" for="secondRadio">Second radio</label>
</li>
<li class="list-group-item">
<input class="form-check-input me-1" type="radio" name="listGroupRadio" value="" id="thirdRadio">
<label class="form-check-label" for="thirdRadio">Third radio</label>
</li>
</ul>
Ungasebenzisa .stretched-link
ku- <label>
s ukwenza yonke into yeqembu lohlu ichofozeke.
<ul class="list-group">
<li class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value="" id="firstCheckboxStretched">
<label class="form-check-label stretched-link" for="firstCheckboxStretched">First checkbox</label>
</li>
<li class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value="" id="secondCheckboxStretched">
<label class="form-check-label stretched-link" for="secondCheckboxStretched">Second checkbox</label>
</li>
<li class="list-group-item">
<input class="form-check-input me-1" type="checkbox" value="" id="thirdCheckboxStretched">
<label class="form-check-label stretched-link" for="thirdCheckboxStretched">Third checkbox</label>
</li>
</ul>
CSS
Okuguquguqukayo
Kwengezwe ku-v5.2.0Njengengxenye yendlela yokuguquguquka ye-CSS ye-Bootstrap, amaqembu ohlu manje asebenzisa okuguquguqukayo kwasendaweni kwe-CSS .list-group
ukuze enze ngokwezifiso isikhathi sangempela esithuthukisiwe. Amanani okuguquguquka kwe-CSS asethwa nge-Sass, ngakho ukwenza ngokwezifiso kwe-Sass kusasekelwa, nakho.
--#{$prefix}list-group-color: #{$list-group-color};
--#{$prefix}list-group-bg: #{$list-group-bg};
--#{$prefix}list-group-border-color: #{$list-group-border-color};
--#{$prefix}list-group-border-width: #{$list-group-border-width};
--#{$prefix}list-group-border-radius: #{$list-group-border-radius};
--#{$prefix}list-group-item-padding-x: #{$list-group-item-padding-x};
--#{$prefix}list-group-item-padding-y: #{$list-group-item-padding-y};
--#{$prefix}list-group-action-color: #{$list-group-action-color};
--#{$prefix}list-group-action-hover-color: #{$list-group-action-hover-color};
--#{$prefix}list-group-action-hover-bg: #{$list-group-hover-bg};
--#{$prefix}list-group-action-active-color: #{$list-group-action-active-color};
--#{$prefix}list-group-action-active-bg: #{$list-group-action-active-bg};
--#{$prefix}list-group-disabled-color: #{$list-group-disabled-color};
--#{$prefix}list-group-disabled-bg: #{$list-group-disabled-bg};
--#{$prefix}list-group-active-color: #{$list-group-active-color};
--#{$prefix}list-group-active-bg: #{$list-group-active-bg};
--#{$prefix}list-group-active-border-color: #{$list-group-active-border-color};
Izinguquko ze-Sass
$list-group-color: $gray-900;
$list-group-bg: $white;
$list-group-border-color: rgba($black, .125);
$list-group-border-width: $border-width;
$list-group-border-radius: $border-radius;
$list-group-item-padding-y: $spacer * .5;
$list-group-item-padding-x: $spacer;
$list-group-item-bg-scale: -80%;
$list-group-item-color-scale: 40%;
$list-group-hover-bg: $gray-100;
$list-group-active-color: $component-active-color;
$list-group-active-bg: $component-active-bg;
$list-group-active-border-color: $list-group-active-bg;
$list-group-disabled-color: $gray-600;
$list-group-disabled-bg: $list-group-bg;
$list-group-action-color: $gray-700;
$list-group-action-hover-color: $list-group-action-color;
$list-group-action-active-color: $body-color;
$list-group-action-active-bg: $gray-200;
Imiksi
Kusetshenziswa ngokuhambisana $theme-colors
nokukhiqiza izigaba ezihlukile zesimo se- .list-group-item
s.
@mixin list-group-item-variant($state, $background, $color) {
.list-group-item-#{$state} {
color: $color;
background-color: $background;
&.list-group-item-action {
&:hover,
&:focus {
color: $color;
background-color: shade-color($background, 10%);
}
&.active {
color: $white;
background-color: $color;
border-color: $color;
}
}
}
}
Iluphu
Iluphu ekhiqiza amakilasi okulungisa nge- list-group-item-variant()
mixin.
// List group contextual variants
//
// Add modifier classes to change text and background color on individual items.
// Organizationally, this must come after the `:hover` states.
@each $state, $value in $theme-colors {
$list-group-variant-bg: shift-color($value, $list-group-item-bg-scale);
$list-group-variant-color: shift-color($value, $list-group-item-color-scale);
@if (contrast-ratio($list-group-variant-bg, $list-group-variant-color) < $min-contrast-ratio) {
$list-group-variant-color: mix($value, color-contrast($list-group-variant-bg), abs($list-group-item-color-scale));
}
@include list-group-item-variant($state, $list-group-variant-bg, $list-group-variant-color);
}
Ukuziphatha kweJavaScript
Sebenzisa i-plugin yethebhu ye-JavaScript—ifake ngayodwa noma bootstrap.js
ngefayela elihlanganisiwe—ukuze unwebe iqembu lethu lohlu ukuze udale amafasitelana angamathebhu okuqukethwe kwasendaweni.
<div class="row">
<div class="col-4">
<div class="list-group" id="list-tab" role="tablist">
<a class="list-group-item list-group-item-action active" id="list-home-list" data-bs-toggle="list" href="#list-home" role="tab" aria-controls="list-home">Home</a>
<a class="list-group-item list-group-item-action" id="list-profile-list" data-bs-toggle="list" href="#list-profile" role="tab" aria-controls="list-profile">Profile</a>
<a class="list-group-item list-group-item-action" id="list-messages-list" data-bs-toggle="list" href="#list-messages" role="tab" aria-controls="list-messages">Messages</a>
<a class="list-group-item list-group-item-action" id="list-settings-list" data-bs-toggle="list" href="#list-settings" role="tab" aria-controls="list-settings">Settings</a>
</div>
</div>
<div class="col-8">
<div class="tab-content" id="nav-tabContent">
<div class="tab-pane fade show active" id="list-home" role="tabpanel" aria-labelledby="list-home-list">...</div>
<div class="tab-pane fade" id="list-profile" role="tabpanel" aria-labelledby="list-profile-list">...</div>
<div class="tab-pane fade" id="list-messages" role="tabpanel" aria-labelledby="list-messages-list">...</div>
<div class="tab-pane fade" id="list-settings" role="tabpanel" aria-labelledby="list-settings-list">...</div>
</div>
</div>
</div>
Ukusebenzisa izibaluli zedatha
Ungakwazi ukwenza kusebenze ukuzulazula kweqembu lohlu ngaphandle kokubhala noma iyiphi i-JavaScript ngokucacisa data-bs-toggle="list"
noma ngento ethile. Sebenzisa lezi zibaluli zedatha ku- .list-group-item
.
<div role="tabpanel">
<!-- List group -->
<div class="list-group" id="myList" role="tablist">
<a class="list-group-item list-group-item-action active" data-bs-toggle="list" href="#home" role="tab">Home</a>
<a class="list-group-item list-group-item-action" data-bs-toggle="list" href="#profile" role="tab">Profile</a>
<a class="list-group-item list-group-item-action" data-bs-toggle="list" href="#messages" role="tab">Messages</a>
<a class="list-group-item list-group-item-action" data-bs-toggle="list" href="#settings" role="tab">Settings</a>
</div>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="home" role="tabpanel">...</div>
<div class="tab-pane" id="profile" role="tabpanel">...</div>
<div class="tab-pane" id="messages" role="tabpanel">...</div>
<div class="tab-pane" id="settings" role="tabpanel">...</div>
</div>
</div>
Nge-JavaScript
Nika amandla into yohlu lwethebhu nge-JavaScript (into ngayinye yohlu idinga ukwenziwa isebenze ngayodwana):
const triggerTabList = document.querySelectorAll('#myTab a')
triggerTabList.forEach(triggerEl => {
const tabTrigger = new bootstrap.Tab(triggerEl)
triggerEl.addEventListener('click', event => {
event.preventDefault()
tabTrigger.show()
})
})
Ungakwazi ukwenza kusebenze into ngayinye yohlu ngezindlela ezimbalwa:
const triggerEl = document.querySelector('#myTab a[href="#profile"]')
bootstrap.Tab.getInstance(triggerEl).show() // Select tab by name
const triggerFirstTabEl = document.querySelector('#myTab li:first-child a')
bootstrap.Tab.getInstance(triggerFirstTabEl).show() // Select first tab
Fade umphumela
Ukuze wenze iphaneli yamathebhu ifiphale, .fade
engeza .tab-pane
. Ifasitelana lethebhu yokuqala kufanele futhi .show
lenze okuqukethwe kokuqala kubonakale.
<div class="tab-content">
<div class="tab-pane fade show active" id="home" role="tabpanel">...</div>
<div class="tab-pane fade" id="profile" role="tabpanel">...</div>
<div class="tab-pane fade" id="messages" role="tabpanel">...</div>
<div class="tab-pane fade" id="settings" role="tabpanel">...</div>
</div>
Izindlela
Izindlela ze-Asynchronous kanye noshintsho
Zonke izindlela ze-API azivumelanisi futhi ziqala inguquko . Babuyele kofonayo uma sekuqalwa uguquko kodwa lungakapheli . Ngokungeziwe, ikholi yendlela engxenyeni yoshintsho izozitshwa .
Bheka imibhalo yethu ye-JavaScript ukuze uthole ulwazi olwengeziwe .
Yenza okuqukethwe kwakho kusebenze njengengxenye yethebhu.
Ungakha isibonelo sethebhu nomakhi, isibonelo:
const bsTab = new bootstrap.Tab('#myTab')
Indlela | Incazelo |
---|---|
dispose |
Icekela phansi ithebhu yento. |
getInstance |
Indlela emile ekuvumela ukuthi uthole isibonelo sethebhu esihlotshaniswa nento ye-DOM, ungayisebenzisa kanje: bootstrap.Tab.getInstance(element) . |
getOrCreateInstance |
Indlela emile ebuyisela isenzakalo sethebhu esihlotshaniswa nento ye-DOM noma idale entsha uma kwenzeka ingaqaliswanga. Ungayisebenzisa kanje bootstrap.Tab.getOrCreateInstance(element) :. |
show |
Ikhetha ithebhu enikeziwe futhi ibonise ifasitelana elihlotshaniswa nayo. Noma iyiphi enye ithebhu ekhethwe ngaphambilini iyayekwa ukukhethwa futhi ifasitelana elihlobene nalo liyafihlwa. Ibuyela kofonayo ngaphambi kokuba kuboniswe ifasitelana lethebhu (okungukuthi ngaphambi kokuba shown.bs.tab kwenzeke umcimbi). |
Imicimbi
Uma ubonisa ithebhu entsha, izehlakalo zivutha ngokulandelana okulandelayo:
hide.bs.tab
(kuthebhu esebenzayo yamanje)show.bs.tab
(kuthebhu ezoboniswa)hidden.bs.tab
(kuthebhu esebenzayo yangaphambilini, efanayohide.bs.tab
neyomcimbi)shown.bs.tab
(kuthebhu esanda kuboniswa, efanayoshow.bs.tab
neyomcimbi)
Uma ingekho ithebhu ebivele iyasebenza, kuzosho ukuthi i- hide.bs.tab
nemicimbi hidden.bs.tab
ngeke kuxoshwe.
Uhlobo lomcimbi | Incazelo |
---|---|
hide.bs.tab |
Lo mcimbi uvutha lapho ithebhu entsha izoboniswa (futhi ngaleyo ndlela ithebhu yangaphambilini esebenzayo izofihlwa). Sebenzisa event.target futhi event.relatedTarget uqondise ithebhu esebenzayo yamanje kanye nethebhu entsha ezosebenza maduze, ngokulandelana. |
hidden.bs.tab |
Lo mcimbi uvutha ngemva kokuboniswa kwethebhu entsha (futhi ngaleyo ndlela ithebhu yangaphambilini esebenzayo ifihliwe). Sebenzisa event.target futhi event.relatedTarget uqondise ithebhu esebenzayo yangaphambilini kanye nethebhu entsha esebenzayo, ngokulandelanayo. |
show.bs.tab |
Lo mcimbi uvutha embukisweni wethebhu, kodwa ngaphambi kokuthi kuboniswe ithebhu entsha. Sebenzisa event.target futhi event.relatedTarget uqondise ithebhu esebenzayo kanye nethebhu esebenzayo yangaphambilini (uma ikhona) ngokulandelanayo. |
shown.bs.tab |
Lo mcimbi uvutha embukisweni wethebhu ngemva kokuthi ithebhu isibonisiwe. Sebenzisa event.target futhi event.relatedTarget uqondise ithebhu esebenzayo kanye nethebhu esebenzayo yangaphambilini (uma ikhona) ngokulandelanayo. |
const tabElms = document.querySelectorAll('a[data-bs-toggle="list"]')
tabElms.forEach(tabElm => {
tabElm.addEventListener('shown.bs.tab', event => {
event.target // newly activated tab
event.relatedTarget // previous active tab
})
})