An warware: nau'in yara

Idan ya zo ga fasahar tufatar da yara, akwai salo da yawa da ya kamata a yi la'akari da su, suna mai da shi aiki mai daษ—i da ban sha'awa. A cikin wannan labarin, za mu bincika wasu shahararrun salon yara, dalla dalla dalla dalla dalla dalla dalla dalla dalla dalla dalla dalla dalla dalla dalla dalla da wadannan salon, har ma da samar da wasu ingantattun shawarwari kan yadda za a iya haษ—awa da daidaita sassa daban-daban na tufafi don gamawa mai kyau.

Kara karantawa

An warware: nau'in tsararrun abubuwa

A cikin duniyar shirye-shirye, yanayin da aka saba ci karo da shi shine buฦ™atuwar tsara jerin abubuwa. Wannan na iya zama kamar mai ban tsoro da farko, musamman a cikin yare mai ฦ™ima kamar Nau'in cuta. Duk da haka, tare da tsarin da ya dace, wannan aikin zai iya zama aikin da za a iya sarrafawa. Wannan ya wuce rarrabuwar haruffa ko lambobi kawai; muna zurfafa zurfafa cikin rarrabuwa ta takamaiman kaddarori ko kaddarorin abubuwa da yawa na tsararrun abu.

Maganin matsalar yawanci ya ฦ™unshi amfani da hanyar tsararru () a haษ—e da tsarin nau'in TypeScript. Anan ga hoto mai sauri na yadda zaku iya ware tsararrun abubuwa ta hanyar 'suna'.

let arr = [{name: 'Joe'}, {name: 'Bob'}, {name: 'Alice'}];
arr.sort((a, b) => a.name.localeCompare(b.name));

A cikin misalin da ke sama, muna amfani da in-built JavaScript Hanyar Array.prototype.sort a haษ—e tare da aikin kwatance dangane da wurare.

Kara karantawa

An warware: yadda ake bincika idan fayil ya wanzu lua

Tabbas, ga daftarin labarin ku:

Fahimtar ฦ™arfi da juzu'in shirye-shiryen Lua yana ba da ฦ™ima mai mahimmanci wajen sarrafa fayiloli ta hanyar da ta dace. Wani muhimmin al'amari da ya kamata a lura dashi shine ikonsa don bincika idan akwai fayil ษ—in. Wannan aikin yana da mahimmanci wajen guje wa kurakurai ko sakamakon da ba a yi niyya ba yayin ayyukan fayil. A yau, muna nufin rarraba tsarin tabbatar da wanzuwar fayil ta amfani da Lua.

Kara karantawa

An warware: useref react

Anan ga yadda zaku iya tsara labarin da kuka nema game da amsa "useref":

React sanannen ษ—akin karatu ne na duniya don ฦ™irฦ™irar mu'amalar masu amfani, musamman aikace-aikacen shafi ษ—aya. Labura ce mai sauฦ™i da sassauฦ™a da aka tsara don haษ“aka ฦ™warewar mai amfani. Ci gaban yanar gizo ya kai sabon sa'o'i tare da fasalulluka kamar Hooks wanda React ya kawo. ฦŠayan irin wannan muhimmin fasalin, ko za ku iya la'akari da shi, ฦ™ugiya da React ya samar shine amfaniRef. UseRef ana amfani da shi gabaษ—aya don samun dama ga nodes na DOM ko abubuwan React.

Kara karantawa

An warware: font madalla angular

Tabbas, ga dogon labarin game da Font Awesome Angular:

Font Awesome babban ษ—akin karatu ne na icon wanda za'a iya amfani dashi a cikin aikace-aikacen mu na Angular. Haษ—a Font Awesome yana ba masu haษ“aka damar zuwa ษ—aruruwan madaidaitan gumaka masu ฦ™ima waษ—anda za a iya keษ“ance su da CSS. Wannan yana da amfani musamman tunda yana ba mu damar amfani da gumaka masu kyau ba tare da buฦ™atar dogaro da yawa akan zane-zane ko fayilolin hoto ba. Wannan na iya sauฦ™aฦ™a da gaske kulawa da tsara ayyukan ku na Angular. A cikin wannan jagorar, za mu koyi yadda ake haษ—a Font Awesome cikin aikace-aikacen ku na Angular mataki-mataki.

Kara karantawa

An warware: akan girman taga

Mayar da taga yana iya zama kamar aiki mara mahimmanci a cikin ci gaban yanar gizo, amma a zahiri yana da alaฦ™a ฦดan ra'ayoyi daga JavaScript da Typescript, kuma yana taka muhimmiyar rawa wajen tabbatar da ฦ™ira mai dacewa da mai amfani. A cikin mahallin UI/UX mai ฦ™arfi, aikin 'taga girman girman' yana da mahimmanci. Misalai na yau da kullun na iya haษ—awa da shingen gefe wanda ke raguwa akan girman taga don ba da sarari karatu mara kyau, ko hoton hoton da ke daidaita kanta don hana murdiya. Ana yin gyare-gyaren a hankali ta hanyar sauraron taron sake girman taga.

Kara karantawa

An warware: watsi da node_modules

A matsayinka na mai haษ“akawa, mai yiwuwa ka yi tafiya a cikin babban fayil 'node_modules' a cikin ayyukanka. Wannan muhimmin bangare ne na duniyar JavaScript da TypeScript, musamman a cikin ayyukan da ke amfani da Node.js. Waษ—annan '' node_modules '' suna kama da DNA don aikinku, gami da duk ษ—akunan karatu ko abubuwan dogaro da lambar ku ke buฦ™atar aiwatarwa daidai. Matsalar ita ce wannan babban fayil na iya girma cikin sauri cikin girma, yana mai da aikin ku nauyi, musamman dangane da tsarin sarrafa sigar. Bugu da ฦ™ari, za a iya samun ษ—imbin rikice-rikice na sigar rubutu idan ba a kula da su daidai ba.

Kara karantawa

An warware: ts queryselectorall as htmlelement

A cikin al'ummar yau inda bayanai suka zama ruwan dare, mu'amala da takaddun HTML ba banda bane. Kowane shafin yanar gizon sararin samaniya an gina shi akan HTML, ฦ™irฦ™irar ragamar labyrinthine na abubuwa da tags. Makullin kewayawa ta wannan ragar cikin tsari da tsari shine ta hanyar amfani da na'urar tambayaSelectorAll Hanyar a JavaScript ko, a cikin yanayinmu a nan, TypeScript. A yau, za mu zurfafa zurfafa cikin yin amfani da damar tambayarSelectorAll azaman HTMLElement a cikin TypeScript.

Kara karantawa

An warware: ts juyi tsararru

Mayar da tsararru a cikin Rubutun Rubutun ya ฦ™unshi ainihin canza tsarin abubuwan da ke cikin tsararru daga jerin abubuwan zuwa akasin haka. Wannan tsari wani muhimmin fanni ne mai mahimmanci wajen sarrafa tsararraki, don haka, zai iya zama mai matuฦ™ar taimako wajen warware matsaloli daban-daban.

The Nau'in cuta harshe ya ฦ™unshi ginanniyar hanyar da aka gina don juyar da tsararraki, wanda aka sani da aikin array.reverse(). Lallai, ta amfani da wannan aikin, muna iya juyar da kowane tsararru a cikin Typescript ba tare da wahala ba.

Don kwatanta amfani da shi, yi la'akari da tsararrun samfurin:

let array = [1, 2, 3, 4, 5];

Zamu iya juyar da wannan tsararru ta amfani da aikin array.reverse() kamar haka:

array = array.reverse();

Wannan aiki zai juyar da tsarin abubuwan da ke cikin asalin tsararru ta yadda jerin sa ya zama akasin abin da yake kafin a yi aikin.

Kara karantawa