Dab tsi yog saib cov khoom hauv MVC?
Dab tsi yog saib cov khoom hauv MVC?

Video: Dab tsi yog saib cov khoom hauv MVC?

Video: Dab tsi yog saib cov khoom hauv MVC?
Video: sib pab ua hmo sawv daws noj os 2024, Hlis ntuj nqeg
Anonim

Saib Component yog qhov tshiab tshaj tawm tshiab hauv ASP. NET Core MVC . Nws zoo ib yam li ib nrab saib tab sis nws muaj zog heev li piv rau nws. Nws tsis siv cov qauv khi tab sis ua haujlwm tsuas yog nrog cov ntaub ntawv peb muab thaum hu rau nws. Saib Component muaj cov yam ntxwv hauv qab no.

Ib yam li ntawd, saib cov ntsiab lus yog dab tsi?

A saib cov ntsiab lus muaj ob ntu: chav kawm (feem ntau muab los ntawm ViewComponent) thiab qhov tshwm sim nws rov qab los (feem ntau yog ib qho saib ). Zoo li controllers, a saib cov ntsiab lus tuaj yeem yog POCO, tab sis feem ntau cov neeg tsim khoom yuav xav ua kom zoo dua ntawm cov txheej txheem thiab cov khoom muaj los ntawm kev muab los ntawm ViewComponent.

Ib yam li ntawd, qhov kev pom ib nrab hauv MVC yog dab tsi? Kev saib ib nrab hauv ASP. NET MVC yog tshwj xeeb saib uas renders ib feem ntawm saib cov ntsiab lus. Nws yog ib yam li tus neeg siv tswj ntawm daim ntawv thov web. Ib nrab tuaj yeem rov siv tau ntau yam saib . Nws pab peb kom txo tau cov lej duplication. Hauv lwm lo lus a ib nrab saib pab kom peb render a saib hauv niam txiv saib.

Kuj Paub, MVC yog dab tsi?

Tus Qauv-Saib-Controller ( MVC ) yog ib qho qauv tsim qauv uas cais ib daim ntawv thov ua peb lub ntsiab lus tseem ceeb cov khoom : tus qauv, qhov pom, thiab tus tswj. MVC yog ib qho ntawm feem ntau siv kev lag luam-tus qauv web tsim lub moj khaum los tsim scalable thiab extensible tej yaam num.

Dab tsi yog rab chais saib hauv MVC?

Razor saib engine hauv asp.net mvc ua yog syntax uas tso cai rau koj sau server sab code rau saib . Nws pab ua ke cov cai thiab html hauv cov kua dej. Razor tsis yog hom lus tshiab yog tias koj paub C#, Vb. Net thiab me ntsis HTML koj tuaj yeem sau tau yooj yim Razor code. Razor txhawb C# thiab Visual Basic programming lus.

Pom zoo: