ES6, qee zaum hu ua ECMAScript 2015, yog tus lej koj yuav pom hauv qee qhov browser, tab sis koj yuav tsum tau khiav Node.js ib puag ncig kom tuaj yeem khiav thiab sau ES6 code. Qhov wikiHow no yuav qhia koj yuav pib sau ES6 code li cas.
Cov kauj ruam
Kauj Ruam 1. Rub tawm thiab teeb tsa Node.js ntawm
Node.js yog ib puag ncig-server ib puag ncig uas koj xav tau siv cov cai. Node.js ua haujlwm rau ob lub Windows thiab macOS.
- Hla cov kauj ruam no yog tias koj twb muaj Node.js teeb tsa hauv koj lub khoos phis tawj.
- Nyem LTS, thawj ntsuab khawm mus rau sab laug. Qhov no yuav teeb tsa qhov ruaj khov ntawm Node.js rau koj lub khoos phis tawj. Yog tias koj siv lub khoos phis tawj Windows, koj yuav zoo li yuav tsum rub cov ntawv rub tawm thiab txuas ntxiv mus los ntawm tus tsim kev teeb tsa. Yog tias koj siv macOS, koj yuav zoo li yuav tsum tau ua cov ntaub ntawv teeb tsa, tom qab ntawd rub thiab tso daim ntawv thov icon rau koj daim ntawv thov.
Kauj Ruam 2. Rub tawm thiab teeb tsa Visual Studio Code ntawm
VSC yog ib txoj haujlwm uas ua haujlwm ntawm ob lub Windows thiab Mac uas tso cai rau koj los tsim ES6 code.
Nyem Rub tawm nyob rau sab xis saum toj ntawm nplooj ntawv yog tias tam sim no Rub tawm rau (koj OS) yog tsis yog. Cov neeg siv Windows yuav xav tau rub tawm cov ntawv rub tawm thiab txuas ntxiv los ntawm kev teeb tsa kev teeb tsa. Yog tias koj siv macOS, koj yuav zoo li yuav tsum tau ua cov ntaub ntawv teeb tsa, tom qab ntawd rub thiab tso daim ntawv thov icon rau koj daim ntawv thov.
Kauj Ruam 3. Tsim daim npliag npliag ntawm koj lub drive lossis duab
Txhawm rau ua qhov no, tsuas yog qhib File Explorer lossis Finder, mus rau qhov chaw (piv txwv li, C tsav) qhov uas koj xav tsim koj daim ntawv tais ceev tseg. Npe nws qee yam yooj yim uas koj yuav nco tau (zoo li "JS" lossis "Nodefolder").
Kauj Ruam 4. Qhib Visual Studio Code
Koj yuav pom qhov no hauv koj li Start Menu lossis Applications folder in Finder.
Kauj Ruam 5. Qhib daim npliag npliag hauv VSC
Mus rau File> Qhib New Folder kom qhib cov ntawv browser thiab xaiv koj cov nplaub tshev uas tsis muaj.
Koj yuav pom koj lub npe lub npe nyob hauv lub vaj huam sib luag ntawm sab laug ntawm daim ntawv thov
Kauj Ruam 6. Tsim cov ntawv hauv koj daim nplaub tshev
Nyem rau nplooj ntawv thiab ntxiv rau kos npe (+) lub cim nyob ib sab ntawm lub npe nplaub tshev.
Lub npe nws qee yam yooj yim, piv txwv li "helloworld.js"
Kauj Ruam 7. Sau cov cai hauv qab no hauv kab ntawv kab ntawv ntawm sab xis
-
console.log ('Nyob zoo ntiaj teb');
Kauj Ruam 8. Kuaj tias txoj cai ua haujlwm
Txij li thaum koj tau teeb tsa Node.js, koj yuav pom lub qhov rai "Terminal" ze rau hauv qab ntawm koj qhov program.
-
Hom
node helloworld.js
- thiab koj yuav tsum tau txais cov lus teb ntawm "Nyob zoo ntiaj teb" hauv kab tom ntej.
- Koj yuav tsum muaj peev xwm tsim ib qho ES6 code koj xav tau ntawm no. Txog cov piv txwv, koj tuaj yeem saib https://www.freecodecamp.org/news/getting-started-with-es6-using-a-few-of-my-favorite-things-ac89c27812e0/ thiab https:// code. visualstudio.com/docs/languages/javascript.