JSX yog dab tsi?
JSX yog dab tsi?

Video: JSX yog dab tsi?

Video: JSX yog dab tsi?
Video: Wen - Kuv Yog Dab Tsi Tiag ( MV Music Video ) Hip Hop 2022 Hnong New Song 2024, Kaum ib hlis
Anonim

JSX yog XML/HTML-zoo li syntax siv los ntawm Teb uas txuas ECMAScript kom XML/HTML-zoo li ntawv tuaj yeem ua ke nrog JavaScript/ Teb code. Tsis zoo li yav dhau los, es tsis txhob muab JavaScript rau hauv HTML, JSX tso cai rau peb tso HTML rau hauv JavaScript.

Kuj tseem paub yog, vim li cas JSX siv rau hauv kev xav?

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.

Tsis tas li ntawd, qhov txawv ntawm JS thiab JSX yog dab tsi? JS yog standard javascript, JSX yog HTML-zoo li syntax uas koj tuaj yeem siv nrog React rau (theoretically) ua kom yooj yim dua thiab nkag siab ntau dua los tsim cov khoom React. Tsis muaj JSX , tsim cov ntaub ntawv loj, nested HTML siv JS syntax yuav mob loj hauv nram qab; JSX tsuas yog ua kom cov txheej txheem ntawd yooj yim dua.

Tsis tas li ntawd, className yog dab tsi nyob rau hauv react?

classNpe . Txhawm rau qhia CSS chav kawm, siv qhov classNpe tus cwj pwm. Qhov no siv rau txhua yam DOM thiab SVG ib txwm muaj xws li,, thiab lwm yam. Yog koj siv Teb nrog Web Cheebtsam (uas yog tsis tshua muaj), siv chav kawm attribute xwb.

JSX sawv rau dab tsi?

JSX sawv rau JavaScript XML. Nrog Teb , nws yog qhov txuas ntxiv rau XML-zoo li code rau cov khoom thiab cov khoom. Rau qhov Teb docs thiab raws li koj tau hais: JSX yog XML-zoo li syntax txuas ntxiv rau ECMAScript yam tsis muaj kev txhais lus.

Pom zoo: