Amathosti
Phusha izaziso kubavakashi bakho ngethosti, umlayezo ongasindi futhi owenzeka ngokwezifiso isixwayiso.
Amathosta ayizaziso ezilula eziklanyelwe ukulingisa izaziso eziye zaduma amasistimu okusebenza eselula nawedeskithophu. Akhiwe nge-flexbox, ngakho kulula ukuwaqondanisa nokuma.
Uhlolojikelele
Izinto okufanele uzazi uma usebenzisa i-plugin ye-toast:
- Uma wakha i-JavaScript yethu ngomthombo, idinga
util.js
. - Amathosti angena ngenxa yezizathu zokusebenza, ngakho-ke kuzomele uwaqalise ngokwakho .
- Sicela uqaphele ukuthi unesibopho sokubeka amathosti.
- Amathosti azofihla ngokuzenzakalelayo uma ungacacisi
autohide: false
.
Umthelela wokugqwayiza wale ngxenye uncike prefers-reduced-motion
embuzweni wemidiya. Bona ingxenye yokunyakaza encishisiwe yemibhalo yethu yokufinyeleleka .
Izibonelo
Okuyisisekelo
Ukuze ukhuthaze amathosi anwebekayo futhi abikezelwe, sincoma unhlokweni nomzimba. Kusetshenziswa izihloko ze -toast display: flex
, ezivumela ukuqondanisa kalula kokuqukethwe ngenxa yezinsiza zethu zemajini kanye ne-flexbox.
Amathosti avumelana nezimo ngendlela oyidingayo futhi anemakhaphu amancane kakhulu adingekayo. Okungenani, sidinga into eyodwa ukuthi iqukathe okuqukethwe kwakho "okuthosiwe" futhi ikhuthaze ngokuqinile inkinobho yokucashisa.
I-Translucent
Amathosti ashintshashintsha kancane, nawo, ngakho ahlangana nanoma yini angavela phezu kwayo. Ezipheqululini ezisekela isici se- backdrop-filter
CSS, sizophinde sizame ukufiphalisa izici ngaphansi kwethosti.
Ukupakisha
Uma unamathosti amaningi, sizenzakalela ukuwapakisha ngokuma ngendlela efundekayo.
Ukubekwa
Beka amathosti nge-CSS yangokwezifiso njengoba uwadinga. Ingaphezulu kwesokudla livame ukusetshenziselwa izaziso, njengoba kunjalo nendawo ephakathi ephezulu. Uma uzobonisa ithosi eyodwa ngesikhathi, beka izitayela zokuma khona kanye ku- .toast
.
Kumasistimu akhiqiza izaziso eziningi, cabanga ukusebenzisa i-elementi yokugoqa ukuze akwazi ukunqwabelanisa kalula.
Ungakwazi futhi ukunethezeka ngezinsiza ze-flexbox ukuze uqondanise amathosta ngokuvundlile kanye/noma ngokuqondile.
Ukufinyeleleka
Amathosi enzelwe ukuthi abe yiziphazamiso ezincane kubavakashi bakho noma abasebenzisi, ngakho-ke ukuze usize labo abanezifundi zesikrini nobuchwepheshe obufanayo bokusiza, kufanele usonge amathosi akho aria-live
endaweni . Izinguquko ezifundeni ezibukhoma (njengokujova/ukubuyekeza ingxenye ye-toast) zimenyezelwa ngokuzenzakalelayo izifundi zesikrini ngaphandle kokudinga ukuhambisa ukugxila komsebenzisi noma ukuphazamisa umsebenzisi. Ukwengeza, faka aria-atomic="true"
ukuze uqinisekise ukuthi yonke ithosti ihlala imenyezelwa njengeyunithi eyodwa (ye-athomu), kunokuba umemezele ukuthi yini eshintshiwe (okungaholela ezinkingeni uma ubuyekeza kuphela ingxenye yokuqukethwe kwethosti, noma uma ubonisa okuqukethwe kwethosti efanayo ngemuva kwesikhathi). Uma ulwazi oludingekayo lubalulekile kunqubo, isb ngohlu lwamaphutha efomini, sebenzisa ingxenye yesixwayiso .esikhundleni se-toast.
Qaphela ukuthi indawo ebukhoma idinga ukuba khona kumakhaphu ngaphambi kokuthi i-toast yenziwe noma ibuyekezwe. Uma ukukhiqiza kokubili ngesikhathi esisodwa futhi ukujove ekhasini, ngokuvamile ngeke kumenyezelwe ngobuchwepheshe obusizayo.
Udinga futhi ukuzivumelanisa role
nezinga aria-live
ngokuya ngokuqukethwe. Uma kungumlayezo obalulekile njengephutha, sebenzisa role="alert" aria-live="assertive"
, uma kungenjalo sebenzisa role="status" aria-live="polite"
izibaluli.
Njengoba okuqukethwe okubonisayo kushintsha, qiniseka ukuthi ubuyekeza delay
ukuphela kwesikhathi ukuze uqinisekise ukuthi abantu banesikhathi esanele sokufunda ithosi.
Uma usebenzisa autohide: false
i-, kufanele wengeze inkinobho yokuvala ukuze uvumele abasebenzisi ukuthi bachithe ithosti.
Ukuziphatha kweJavaScript
Ukusetshenziswa
Qalisa ama-toast nge-JavaScript:
Izinketho
Izinketho zingadluliswa ngezibaluli zedatha noma i-JavaScript. Ukuze uthole izibaluli zedatha, faka igama lenketho kokuthi data-
, njengaku data-animation=""
.
Igama | Uhlobo | Okuzenzakalelayo | Incazelo |
---|---|---|---|
izithombe | boolean | iqiniso | Faka inguquko ye-CSS fade ku-toast |
fihla ngokuzenzakalelayo | boolean | iqiniso | Fihla ngokuzenzakalelayo ithosi |
ukubambezela | inombolo | 500 |
Libazisa ukufihla ithosti (ms) |
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 .
$().toast(options)
Inamathisela isibambi se-toast eqoqweni lesici.
.toast('show')
Iveza ithosi yento. Ibuyela kofonayo ngaphambi kokuthi kuboniswe ithosi (okungukuthi ngaphambi kokuba shown.bs.toast
umcimbi wenzeke). Kufanele ushayele le ndlela mathupha, kunalokho ithosi lakho ngeke livele.
.toast('hide')
Ifihla ithosi yento. Ibuyela kofonayo ngaphambi kokuthi ithosi ifihlekile (okungukuthi ngaphambi kokuthi hidden.bs.toast
kwenzeke umcimbi). Kufanele ushayele le ndlela mathupha uma wenze autohide
ku- false
.
.toast('dispose')
Ifihla ithosi yento. Ithosi lakho lizohlala ku-DOM kodwa ngeke lisavela.
Imicimbi
Uhlobo Lomcimbi | Incazelo |
---|---|
show.bs.toast | Lo mcimbi uvutha ngokushesha lapho show indlela yesibonelo ibizwa. |
kubonisiwe.bs.toast | Lo mcimbi uxoshwa lapho i-toast yenziwe yabonakala kumsebenzisi. |
fihla.bs.toast | Lo mcimbi uxoshwa ngokushesha lapho hide indlela yesibonelo ibizwa. |
kufihliwe.bs.toast | Lo mcimbi uxoshwa lapho ithosti isiqedile ukufihlwa kumsebenzisi. |