Dab tsi yog qhov txawv ntawm qhov xav tau thiab txhais hauv RequireJS?
Dab tsi yog qhov txawv ntawm qhov xav tau thiab txhais hauv RequireJS?

Video: Dab tsi yog qhov txawv ntawm qhov xav tau thiab txhais hauv RequireJS?

Video: Dab tsi yog qhov txawv ntawm qhov xav tau thiab txhais hauv RequireJS?
Video: Qhia txhais 50 zaj npau suav tias yog dab tsi part 3 15 Sep 2019 2024, Kaum ib hlis
Anonim

xav tau () thiab txhais () ob leeg siv los thauj cov kev vam meej. Xav tau (): Txoj kev yog siv los khiav haujlwm tam sim ntawd. txhais (): Txoj kev siv rau txhais modules siv rau ntau qhov chaw (rov siv dua).

Raws li, dab tsi yog txhais hauv RequireJS?

Cov txhais () muaj nuj nqi tuaj yeem siv los thauj cov modules (module tuaj yeem yog ib qho khoom, muaj nuj nqi, chav kawm lossis tus lej uas raug tua tom qab thauj khoom). Koj tuaj yeem thauj khoom sib txawv ntawm tib lub module hauv tib nplooj ntawv.

Qhov thib ob, koj puas siv CommonJS? Node. js thiab RingoJS yog server-sab JavaScript runtimes, thiab yog, ob qho tib si siv cov qauv raws li qhov CommonJS Module spec. AMD feem ntau yog ntau dua siv nyob rau hauv tus neeg siv-sab (hauv-browser) JavaScript txhim kho vim qhov no, thiab CommonJS Module yog feem ntau siv server-sab.

Ib sab saum toj no, RequireJS thauj cov ntaub ntawv li cas?

Xav tauJS siv Asynchronous Module Chaw thau khoom (AMD) rau loading cov ntaub ntawv . Txhua qhov nyob ntawm qhov module yuav pib thauj khoom los ntawm asynchronous thov nyob rau hauv qhov kev txiav txim muab. Txawm tias cov ntaub ntawv kev txiav txim yog txiav txim siab, peb tsis tuaj yeem lav tias thawj ntaub ntawv yog loaded ua ntej thib ob ntaub ntawv vim lub asynchronous xwm.

Puas xav tau synchronous?

Xav tau - synchronous tso cai rau koj thauj cov code optimized thiab ua tiav tam sim ntawd, qhov twg koj xav tau. Yog vim li cas lub tsev qiv ntawv no tau sau yog tso cai synchronous legacy code yuav tsum tau hloov nrog Xav tau.

Pom zoo: