Okulandelayo.js 9.3 iza nenkxaso yokudala indawo emileyo, ukulungiswa kwe-404 kunye nokunye

Okulandelayo.js 9.3

Okulandelayo.js sisakhelo seReact sokunikezelwa kwicala leseva, Eboniswa ngabadali bayo njengesixhobo sokumisela isixhobo esinezixhobo ezizodwa zesicelo seReact.

Esi sakhelo ibonelela ngolwakhiwo oluqhelekileyo olukuvumela ukuba wenze ngokulula isicelo seReact ngaphambili kwaye ulawula ngokungafihlisiyo ekunikezeleni kwicala leseva. Inguqulelo ye-js 9.3 yaziswa ngoMvulo ngeempawu ezintsha kunye nokuphuculwa okuthile, esinokuthi sifumane amandla okuvelisa iisayithi ezimileyo njengeyona nto iphambili.

Yintoni entsha ngokulandelayo.js 9.3?

Ngokukhutshwa kweLandelayo.js 9.0, Isakhelo sazise umxholo wokusebenza okuzenzekelayo. Xa a iphepha alinazimfuneko zokuthintela ukubuyiswa kwedatha njenge-GetInitialProps, iya kunikezela ngokuzenzekelayo kwi-HTML sakuba sakhiwe.

Kukho amanye amatyala apho unokufuna ukwenza iphepha kwi-static HTML ngexesha lokudibanisa, nokuba uvimba iimfuno zokukhupha idatha. Yiyo imeko, umzekelo, yamaphepha entengiso inikwe amandla yinkqubo yolawulo lomxholo (CMS).

Okulandelayo.js 9.3 yazisa ngeendlela ezimbini zokubuyisela idatha: getStaticProps kunye getServerSideProps.

Ezi ndlela zintsha unezibonelelo ezininzi ngaphezulu kwemodeli ye-GetInitialPropsnjengoko kukho umahluko ocacileyo phakathi kwento eya kuba yi-SSG (iStatic Side Generation) kunye ne-SSR (iServer Side Rendering). Zizongezo ze-API.

Zonke izinto ezintsha zibuyela umva ziyahambelana kwaye zinokwamkelwa ngokuthe ngcembe. Akukho kuncipha kwaye i-GetInitialProps iyaqhubeka nokusebenza ngokuqhelekileyo. Ipharamitha ye-GetStaticPaths yongezwa ukufumana umzila onamandla.

  • GetStaticProps: ivumela ukufumana idatha ngexesha lokwakha;
  • getStaticPaths-Chaza ukuhamba kwedatha okusekwe kwidatha;
  • getServerSideProps: ikuvumela ukuba ufumane idatha yesicelo ngasinye.

Olunye utshintsho olwahlukileyo kule nguqulo intsha yinkxaso yemowudi yokujonga kuqala. Kwaziswa i-GetStaticProps kwiLandelayo ivula amathuba amatsha, njengokusebenzisa okulandelayo.js enikezela amandla kwimfuno phantsi kweemeko ezithile.

Ngokomzekelo, xa ujonga uyilo Kwi-CMS, uya kufuna ukutsiba unikezelo olungashukumiyo kunye Nika iphepha kwimfuno nomxholo oyilwayo endaweni yomxholo opapashiweyo. Ufuna Okulandelayo.js ukutsiba ukuma okungagungqiyo kule meko. Ngokweqela elilandelayo.js, imowudi yokujonga kwangaphambili ikuvumela ukuba wenze oku.

Indlela ye ukujonga kwangaphambili kuvumela abasebenzisi ukutsiba iphepha elenziweyo ngokokubuyisa ukubuya kwisicelo (i-SSR) iphepha eliyidrafti, umzekelo kwi-CMS. Nangona kunjalo, ayikhawulelwanga kwiinkqubo ezithile zeCMS. Imowudi yokujonga kwangaphambili idibanisa ngokuthe ngqo kunye ne-GetStaticProps kunye ne-GetServerSideProps ukuze isetyenziswe nangaluphi na uhlobo lwesisombululo sokubuyisa idatha.

Okulandelayo.js 9.2 yongeze inkxaso yeCSS eyakhelweyo, kodwa Okulandelayo.js 9.3 yongeze inkxaso yeSass. Amashiti esitayile sehlabathi kunye neemodyuli zeCSS ziyaxhaswa, kunye ne-CSS efakwe ngaphakathi. Okulandelayo.js ngoku ixhasa iimodyuli zeCSS ngeefayile zeSass usebenzisa ifayile ebizwa ngegama lendibano [igama] .module.scss. Ngokungafaniyo nenkxaso ebifunyenwe ngaphambili kwi-Next.js 5+ nge-next-sass, iimodyuli ze-Sass kunye ne-CSS zehlabathi ngoku zinokuhlangana.

Iimodyuli I-CSS ikuvumela ukuba ulawule i-Sass ekuhlaleni ngokwenza ngokuzenzekelayo amagama eklasi awodwa.

Ngohlobo 9.0 ukusuka Okulandelayo.js, Kwakukho iphepha elalinganikezelwanga ngokuzenzekelayo kwi-HTML static: 404 iphepha.

Esona sizathu siphambili soku kukuba iphepha elinempazamo lokondla ama-404 liphathwe ngaphezulu kwama-404. Umzekelo, ikwaphethe iimpazamo. Kuba amaphepha angama-404 enikezelwe ngeendlela ezingekhoyo, Ukunikezela ngephepha kwimfuno kunokukhokelela kwiindleko eziphezulu kunye nomthwalo ophezulu umncedisi Inguqulelo yesakhelo 9.3 iphucula izinto kwaye ibonelela ngokusebenza okuzenzekelayo okungagungqiyo yamaphepha angama-404.

Ngoku xa isicelo sakho singabandakanyi iphutha.js iphepha lesiko, ifayile Okulandelayo.js ngokuzenzekelayo kuvelisa iphepha lama-404 ngokwezibalo kwaye iyisebenzisa xa kufuneka kunikezelwe ngo-404. Oku kuyenzeka ngokuzenzekelayo kwaye akukho lutshintsho lufunekayo.

Unokwenza eli phepha ngokwezifiso. Ukutshintsha iphepha elingagqibekanga elingu-404, unokwenza ifayile engama-404.

Ukuba ufuna ukwazi ngakumbi ngayo, unokuthetha eli khonkco lilandelayo. 


Umxholo wenqaku uyabambelela kwimigaqo yethu imigaqo yokuziphatha yokuhlela. Ukuxela impazamo cofa apha.

Yiba ngowokuqala ukuphawula

Shiya uluvo lwakho

Idilesi yakho ye email aziyi kupapashwa. ezidingekayo ziphawulwe *

*

*

  1. Uxanduva lwedatha: UMiguel Ángel Gatón
  2. Injongo yedatha: Ulawulo lwe-SPAM, ulawulo lwezimvo.
  3. Umthetho: Imvume yakho
  4. Unxibelelwano lwedatha: Idatha ayizukuhanjiswa kubantu besithathu ngaphandle koxanduva lomthetho.
  5. Ukugcinwa kweenkcukacha
  6. Amalungelo: Ngalo naliphi na ixesha unganciphisa, uphinde uphinde ucime ulwazi lwakho.