Vim li cas peb thiaj siv JSX hauv react JS?
Vim li cas peb thiaj siv JSX hauv react JS?

Video: Vim li cas peb thiaj siv JSX hauv react JS?

Video: Vim li cas peb thiaj siv JSX hauv react JS?
Video: 🥰💯 vim li cas peb thiaj yuav tau siv lotion tiv thaiv tus kheej ❤️❤️ 2024, Kaum ib hlis
Anonim

JSX yog ib tug syntax extension rau ReactJS uas ntxiv kev txhawb nqa rau kev sau HTML cim npe hauv JavaScript. Nyob saum ReactJS , nws tsim txoj hauv kev muaj zog heev los nthuav qhia lub vev xaib daim ntawv thov . Yog koj paub ReactJS , koj paub tias nws yog ib lub tsev qiv ntawv rau kev siv lub web tivthaiv-based frontend applications.

Ntawm no, vim li cas JSX thiaj li raug siv los ua qhov tshwm sim?

JSX tso cai rau peb sau cov ntsiab lus HTML hauv JavaScript thiab muab tso rau hauv DOM yam tsis muaj cov txheej txheem createElement() thiab/los yog appendChild() txoj kev. JSX converts HTML tags rau hauv teb cov ntsiab lus. Koj tsis tas yuav siv JSX , mas JSX ua kom yooj yim sau Teb daim ntawv thov.

Qhov thib ob, yuav tsum React cov ntaub ntawv yog JS lossis JSX? Yog li koj raug yuam kom siv JS cov ntaub ntawv tsis yog JSX . Thiab txij li thaum teb tsuas yog lub tsev qiv ntawv rau javascript, nws tsis muaj qhov txawv rau koj xaiv ntawm JSX los yog JS . Lawv nyob nraum interchangeable kiag li! Li no tag nrho React cov ntaub ntawv uas muaj lawv yog JSX thiab tsis JS.

Tsis tas li ntawd, JSX yog dab tsi hauv kev xav?

JSX yog cov kauj ruam ua ntej uas ntxiv XML syntax rau JavaScript. Koj tuaj yeem siv tau tiag tiag Teb tsis muaj JSX tab sis JSX ua Teb ntau elegant. Ib yam li XML, JSX tag muaj lub npe tag, yam ntxwv, thiab me nyuam. Yog hais tias tus nqi attribute yog nyob rau hauv quotes, tus nqi yog ib txoj hlua.

Koj puas tuaj yeem siv JavaScript hauv kev xav?

Teb yog xwb JavaScript , muaj API me me los kawm, tsuas yog ob peb lub luag haujlwm thiab yuav ua li cas siv lawv. Tom qab ntawd, koj JavaScript kev txawj ntse yog qhov ua koj zoo dua Teb tus tsim tawm. Tsis muaj kev txwv rau kev nkag. A JavaScript tus tsim tawm ua tau ua tus tsim khoom Teb tus tsim tawm hauv ob peb teev.

Pom zoo: