Π·Π°ΠΏΡΡΡΠΈΡΡ javascript ΠΊΠΎΠ΄ Ρ Π΄Π΅Π±Π°Π³ΠΎΠΌ Π² visual studio code
ΠΡΠ»Π°Π΄ΠΊΠ° JavaScript Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ Π² Visual Studio
ΠΠΊΠ½ΠΎ ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ JavaScript ΠΌΠΎΠΆΠ½ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Π΄Π»Ρ Π²Π·Π°ΠΈΠΌΠΎΠ΄Π΅ΠΉΡΡΠ²ΠΈΡ ΠΈ ΠΎΡΠ»Π°Π΄ΠΊΠΈ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ UWP, ΡΠΎΠ·Π΄Π°Π½Π½ΡΡ Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ JavaScript. ΠΡΠΈ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΠΈ ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°ΡΡΡΡ Π΄Π»Ρ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ UWP ΠΈ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ, ΡΠΎΠ·Π΄Π°Π½Π½ΡΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ Π‘ΡΠ΅Π΄ΡΡΠ² Π΄Π»Ρ Apache Cordova Π² Visual Studio. Π‘ΠΏΡΠ°Π²ΠΎΡΠ½ΠΈΠΊ ΠΏΠΎ ΠΊΠΎΠ½ΡΠΎΠ»ΡΠ½ΡΠΌ ΠΊΠΎΠΌΠ°Π½Π΄Π°ΠΌ ΡΠΌ. Π² ΡΠ°Π·Π΄Π΅Π»Π΅ JavaScript Console commands.
ΠΠΊΠ½ΠΎ ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ JavaScript ΠΏΡΠ΅Π΄ΠΎΡΡΠ°Π²Π»ΡΠ΅Ρ Π²Π°ΠΌ ΡΠ»Π΅Π΄ΡΡΡΠΈΠ΅ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΠΈ:
ΠΡΠΏΡΠ°Π²ΠΊΠ° ΠΎΠ±ΡΠ΅ΠΊΡΠΎΠ², Π·Π½Π°ΡΠ΅Π½ΠΈΠΉ ΠΈ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠΉ ΠΈΠ· ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ Π² ΠΎΠΊΠ½ΠΎ ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ.
ΠΡΠΎΡΠΌΠΎΡΡ ΠΈ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠ΅ Π·Π½Π°ΡΠ΅Π½ΠΈΠΉ Π»ΠΎΠΊΠ°Π»ΡΠ½ΡΡ ΠΈ Π³Π»ΠΎΠ±Π°Π»ΡΠ½ΡΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ Π² Π·Π°ΠΏΡΡΠ΅Π½Π½ΠΎΠΌ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΈ.
ΠΡΠΎΡΠΌΠΎΡΡ Π²ΠΈΠ·ΡΠ°Π»ΠΈΠ·Π°ΡΠΎΡΠΎΠ² ΠΎΠ±ΡΠ΅ΠΊΡΠΎΠ².
ΠΠ°ΠΏΡΡΠΊ ΠΊΠΎΠ΄Π° JavaScript, ΠΊΠΎΡΠΎΡΡΠΉ Π²ΡΠΏΠΎΠ»Π½ΡΠ΅ΡΡΡ Π² ΡΠ΅ΠΊΡΡΠ΅ΠΌ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ΅ ΡΠΊΡΠΈΠΏΡΠ°.
ΠΡΠΎΡΠΌΠΎΡΡ ΠΎΡΠΈΠ±ΠΎΠΊ ΠΈ ΠΈΡΠΊΠ»ΡΡΠ΅Π½ΠΈΠΉ JavaScript Π² Π΄ΠΎΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΠΊ ΠΈΡΠΊΠ»ΡΡΠ΅Π½ΠΈΡΠΌ ΠΌΠΎΠ΄Π΅Π»ΠΈ DOM ΠΈ ΡΡΠ΅Π΄Ρ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ Windows.
Π‘ ΠΏΠΎΠΌΠΎΡΡΡ ΠΎΠΊΠ½Π° ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ JavaScript ΠΌΠΎΠΆΠ½ΠΎ Π²Π·Π°ΠΈΠΌΠΎΠ΄Π΅ΠΉΡΡΠ²ΠΎΠ²Π°ΡΡ Ρ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ΠΌ, Π½Π΅ ΠΎΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Ρ ΠΈ Π½Π΅ ΠΏΠ΅ΡΠ΅Π·Π°ΠΏΡΡΠΊΠ°Ρ ΠΎΡΠ»Π°Π΄ΡΠΈΠΊ. ΠΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΡΠ΅ ΡΠ²Π΅Π΄Π΅Π½ΠΈΡ ΡΠΌ. Π² ΡΡΠ°ΡΡΠ΅ ΠΎΠ± ΠΎΠ±Π½ΠΎΠ²Π»Π΅Π½ΠΈΠΈ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ JavaScript. Π‘Π²Π΅Π΄Π΅Π½ΠΈΡ ΠΎ Π΄ΡΡΠ³ΠΈΡ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡΡ ΠΎΡΠ»Π°Π΄ΠΊΠΈ JavaScript, ΡΠ°ΠΊΠΈΡ ΠΊΠ°ΠΊ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ ΠΡΠΎΠ²ΠΎΠ΄Π½ΠΈΠΊΠ° DOM ΠΈ Π·Π°Π΄Π°Π½ΠΈΠ΅ ΡΠΎΡΠ΅ΠΊ ΠΎΡΡΠ°Π½ΠΎΠ²Π°, ΡΠΌ. Π² ΡΡΠ°ΡΡΡΡ ΠΡΠ°ΡΠΊΠΎΠ΅ ΡΡΠΊΠΎΠ²ΠΎΠ΄ΡΡΠ²ΠΎ. ΠΡΠ»Π°Π΄ΠΊΠ° ΡΠ°ΠΉΠ»ΠΎΠ² HTML ΠΈ CSS ΠΈ ΠΡΠ»Π°Π΄ΠΊΠ° ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ Π² Visual Studio.
ΠΡΠ»Π°Π΄ΠΊΠ° Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ ΠΎΠΊΠ½Π° ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ JavaScript
ΠΠ°Π»Π΅Π΅ ΠΏΡΠΈΠ²Π΅Π΄Π΅Π½Π° ΠΏΡΠΎΡΠ΅Π΄ΡΡΠ° ΡΠΎΠ·Π΄Π°Π½ΠΈΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ FlipView ΠΈ ΠΈΠ½ΡΡΡΡΠΊΡΠΈΠΈ ΠΏΠΎ ΠΈΠ½ΡΠ΅ΡΠ°ΠΊΡΠΈΠ²Π½ΠΎΠΉ ΠΎΡΠ»Π°Π΄ΠΊΠ΅ ΠΎΡΠΈΠ±ΠΊΠΈ ΠΊΠΎΠ΄ΠΈΡΠΎΠ²Π°Π½ΠΈΡ JavaScript.
ΠΠ΄Π΅ΡΡ Π² ΠΊΠ°ΡΠ΅ΡΡΠ²Π΅ ΠΏΡΠΈΠΌΠ΅ΡΠ° ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ UWP. ΠΠ΄Π½Π°ΠΊΠΎ ΠΎΠΏΠΈΡΡΠ²Π°Π΅ΠΌΡΠ΅ Π·Π΄Π΅ΡΡ ΡΡΠ½ΠΊΡΠΈΠΈ ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ ΡΠ°ΠΊΠΆΠ΅ ΠΏΡΠΈΠΌΠ΅Π½ΠΈΠΌΡ ΠΊ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡΠΌ, ΡΠΎΠ·Π΄Π°Π½Π½ΡΠΌ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΠΎΠ² Visual Studio Π΄Π»Ρ Apache Cordova.
ΠΡΠ»Π°Π΄ΠΊΠ° ΠΊΠΎΠ΄Π° JavaScript Π² ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΈ FlipView
Π‘ΠΎΠ·Π΄Π°ΠΉΡΠ΅ Π½ΠΎΠ²ΠΎΠ΅ ΡΠ΅ΡΠ΅Π½ΠΈΠ΅ Π² Visual Studio, Π²ΡΠ±ΡΠ°Π² Π€Π°ΠΉΠ» > ΠΠΎΠ²ΡΠΉ ΠΏΡΠΎΠ΅ΠΊΡ.
ΠΡΠ±Π΅ΡΠΈΡΠ΅ ΡΠ»Π΅ΠΌΠ΅Π½ΡΡ JavaScript > Π£Π½ΠΈΠ²Π΅ΡΡΠ°Π»ΡΠ½Π°Ρ ΠΏΠ»Π°ΡΡΠΎΡΠΌΠ° Windows, Π° Π·Π°ΡΠ΅ΠΌ ΡΠ»Π΅ΠΌΠ΅Π½Ρ ΠΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ WinJS.
Π ΡΠ»Π΅ΠΌΠ΅Π½ΡΠ΅ BODY ΡΠ°ΠΉΠ»Π° index.HTML Π·Π°ΠΌΠ΅Π½ΠΈΡΠ΅ ΡΡΡΠ΅ΡΡΠ²ΡΡΡΠΈΠΉ ΠΊΠΎΠ΄ HTML ΡΠ»Π΅Π΄ΡΡΡΠΈΠΌ ΠΊΠΎΠ΄ΠΎΠΌ:
ΠΡΠΊΡΠΎΠΉΡΠ΅ ΡΠ°ΠΉΠ» default.css ΠΈ Π΄ΠΎΠ±Π°Π²ΡΡΠ΅ ΡΠ»Π΅Π΄ΡΡΡΠΈΠΉ ΠΊΠΎΠ΄ CSS Π΄Π»Ρ ΡΠ΅Π»Π΅ΠΊΡΠΎΡΠ° #fView :
ΠΡΠΊΡΠΎΠΉΡΠ΅ ΡΠ°ΠΉΠ» default.js ΠΈ Π·Π°ΠΌΠ΅Π½ΠΈΡΠ΅ ΠΊΠΎΠ΄ ΡΠ»Π΅Π΄ΡΡΡΠΈΠΌ ΠΊΠΎΠ΄ΠΎΠΌ JavaScript:
ΠΡΠ»ΠΈ ΡΠ΅Π»Ρ ΠΎΡΠ»Π°Π΄ΠΊΠΈ Π΅ΡΠ΅ Π½Π΅ Π²ΡΠ±ΡΠ°Π½Π°, Π½Π° ΠΏΠ°Π½Π΅Π»ΠΈ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΠΎΠ² ΠΡΠ»Π°Π΄ΠΊΠ° Π² ΡΠ°ΡΠΊΡΡΠ²Π°ΡΡΠ΅ΠΌΡΡ ΡΠΏΠΈΡΠΊΠ΅ ΡΡΠ΄ΠΎΠΌ Ρ ΠΊΠ½ΠΎΠΏΠΊΠΎΠΉ Π£ΡΡΡΠΎΠΉΡΡΠ²ΠΎ Π²ΡΠ±Π΅ΡΠΈΡΠ΅ ΠΠΎΠΊΠ°Π»ΡΠ½ΡΠΉ ΠΊΠΎΠΌΠΏΡΡΡΠ΅Ρ.
ΠΠ°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ»Π°Π²ΠΈΡΡ F5, ΡΡΠΎΠ±Ρ Π·Π°ΠΏΡΡΡΠΈΡΡ ΠΎΡΠ»Π°Π΄ΡΠΈΠΊ.
ΠΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π²ΡΠΏΠΎΠ»Π½ΡΠ΅ΡΡΡ, Π½ΠΎ ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΡ ΠΎΡΡΡΡΡΡΠ²ΡΡΡ. ΠΡΠΈΠ±ΠΊΠΈ APPHOST Π² ΠΎΠΊΠ½Π΅ ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ JavaScript ΡΠΊΠ°Π·ΡΠ²Π°ΡΡ Π½Π° ΠΎΡΡΡΡΡΡΠ²ΠΈΠ΅ ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠΉ.
ΠΠΎ Π²ΡΠ΅ΠΌΡ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ FlipView Π² ΡΡΡΠΎΠΊΠ΅ Π²Π²ΠΎΠ΄Π° ΠΎΠΊΠ½Π° ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ (ΡΡΠ΄ΠΎΠΌ Ρ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠΌ «>>») Π²Π²Π΅Π΄ΠΈΡΠ΅ Data.items ΠΈ Π½Π°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ»Π°Π²ΠΈΡΡ ΠΠΠΠ.
Π’Π°ΠΊΠΆΠ΅ ΠΎΠ±ΡΠ°ΡΠΈΡΠ΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅ Π½Π° ΡΠΎ, ΡΡΠΎ Π² ΠΎΠ±ΡΠ΅ΠΊΡΠ΅ items._data ΡΡΡΠ΅ΡΡΠ²ΡΠ΅Ρ Π½Π°ΠΌΠ½ΠΎΠ³ΠΎ Π±ΠΎΠ»ΡΡΠ΅ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ², ΡΠ΅ΠΌ ΠΎΠΆΠΈΠ΄Π°Π»ΠΎΡΡ.
Π§ΡΠΎΠ±Ρ ΡΡΡΡΠ°Π½ΠΈΡΡ ΡΡΡ ΠΏΡΠΎΠ±Π»Π΅ΠΌΡ Π² ΠΈΠ½ΡΠ΅ΡΠ°ΠΊΡΠΈΠ²Π½ΠΎΠΌ ΡΠ΅ΠΆΠΈΠΌΠ΅ Π±Π΅Π· ΠΎΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ ΡΠ΅Π°Π½ΡΠ° ΠΎΡΠ»Π°Π΄ΠΊΠΈ, ΠΎΡΠΊΡΠΎΠΉΡΠ΅ ΡΠ°ΠΉΠ» default.js ΠΈ Π²ΡΠ±Π΅ΡΠΈΡΠ΅ ΡΡΠΎΡ ΠΊΠΎΠ΄ ΡΡΠ½ΠΊΡΠΈΠΈ updateImages :
Π‘ΠΊΠΎΠΏΠΈΡΡΠΉΡΠ΅ ΠΈ Π²ΡΡΠ°Π²ΡΡΠ΅ ΡΡΠΎΡ ΠΊΠΎΠ΄ Π² ΡΡΡΠΎΠΊΡ Π²Π²ΠΎΠ΄Π° ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ JavaScript.
ΠΡΠΈ Π²ΡΡΠ°Π²ΠΊΠ΅ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΈΡ ΡΡΡΠΎΠΊ ΠΊΠΎΠ΄Π° Π² ΡΡΡΠΎΠΊΡ Π²Π²ΠΎΠ΄Π° ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ JavaScript ΡΡΡΠΎΠΊΠ° Π²Π²ΠΎΠ΄Π° ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ Π°Π²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΈ ΠΏΠ΅ΡΠ΅ΠΊΠ»ΡΡΠ°Π΅ΡΡΡ Π² ΠΌΠ½ΠΎΠ³ΠΎΡΡΡΠΎΡΠ½ΡΠΉ ΡΠ΅ΠΆΠΈΠΌ. ΠΠΎΠΆΠ½ΠΎ Π½Π°ΠΆΠ°ΡΡ ΡΠΎΡΠ΅ΡΠ°Π½ΠΈΠ΅ ΠΊΠ»Π°Π²ΠΈΡ Ctrl + Alt + M Π΄Π»Ρ Π²ΠΊΠ»ΡΡΠ΅Π½ΠΈΡ ΠΈ ΠΎΡΠΊΠ»ΡΡΠ΅Π½ΠΈΡ ΠΌΠ½ΠΎΠ³ΠΎΡΡΡΠΎΡΠ½ΠΎΠ³ΠΎ ΡΠ΅ΠΆΠΈΠΌΠ°. Π§ΡΠΎΠ±Ρ Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡ ΡΠΊΡΠΈΠΏΡ Π² ΠΌΠ½ΠΎΠ³ΠΎΡΡΡΠΎΡΠ½ΠΎΠΌ ΡΠ΅ΠΆΠΈΠΌΠ΅, Π½Π°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ»Π°Π²ΠΈΡΠΈ Ctrl + ΠΠ²ΠΎΠ΄ ΠΈΠ»ΠΈ Π²ΡΠ±Π΅ΡΠΈΡΠ΅ ΡΠΈΠΌΠ²ΠΎΠ» ΡΡΡΠ΅Π»ΠΊΠΈ Π² ΠΏΡΠ°Π²ΠΎΠΌ Π½ΠΈΠΆΠ½Π΅ΠΌ ΡΠ³Π»Ρ ΠΎΠΊΠ½Π°. ΠΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΡΠ΅ ΡΠ²Π΅Π΄Π΅Π½ΠΈΡ ΡΠΌ. Π² ΡΠ°Π·Π΄Π΅Π»Π΅ ΠΠ΄Π½ΠΎΡΡΡΠΎΡΠ½ΡΠΉ ΠΈ ΠΌΠ½ΠΎΠ³ΠΎΡΡΡΠΎΡΠ½ΡΠΉ ΡΠ΅ΠΆΠΈΠΌ Π² ΠΎΠΊΠ½Π΅ ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ JavaScript.
ΠΡΠ±Π΅ΡΠΈΡΠ΅ ΡΠΈΠΌΠ²ΠΎΠ» Π·Π΅Π»Π΅Π½ΠΎΠΉ ΡΡΡΠ΅Π»ΠΊΠΈ, ΡΡΠΎΠ±Ρ Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡ ΡΠΊΡΠΈΠΏΡ.
ΠΠ°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ»Π°Π²ΠΈΡΠΈ CTRL+ALT+M, ΡΡΠΎΠ±Ρ ΠΏΠ΅ΡΠ΅ΠΊΠ»ΡΡΠΈΡΡ ΡΡΡΠΎΠΊΡ Π²Π²ΠΎΠ΄Π° ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ Π² ΠΎΠ΄Π½ΠΎΡΡΡΠΎΡΠ½ΡΠΉ ΡΠ΅ΠΆΠΈΠΌ, Π° Π·Π°ΡΠ΅ΠΌ Π²ΡΠ±Π΅ΡΠΈΡΠ΅ ΠΡΠΈΡΡΠΈΡΡ Π²Ρ ΠΎΠ΄Π½ΡΡ ΡΡΡΠΎΠΊΡ (ΠΊΡΠ°ΡΠ½ΡΠΉ Π·Π½Π°ΡΠΎΠΊ «X») ΡΡΠΎΠ±Ρ ΡΠ΄Π°Π»ΠΈΡΡ ΠΊΠΎΠ΄ ΠΈΠ· ΡΡΡΠΎΠΊΠΈ Π²Π²ΠΎΠ΄Π°.
ΠΠ²Π΅Π΄ΠΈΡΠ΅ Π² ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠ΅ Data.items.length = 3 ΠΈ Π½Π°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ»Π°Π²ΠΈΡΡ ΠΠΠΠ. ΠΡΠΎ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ ΡΠ΄Π°Π»ΠΈΡΡ Π»ΠΈΡΠ½ΠΈΠ΅ ΡΠ»Π΅ΠΌΠ΅Π½ΡΡ Π΄Π°Π½Π½ΡΡ .
Π ΠΎΠ±ΠΎΠ·ΡΠ΅Π²Π°ΡΠ΅Π»Π΅ DOM ΠΎΡΠΎΠ±ΡΠ°ΠΆΠ°Π΅ΡΡΡ ΠΎΠ±Π½ΠΎΠ²Π»Π΅Π½Π½ΡΠΉ ΡΠ»Π΅ΠΌΠ΅Π½Ρ DIV, ΠΈ ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠ΅ΡΠ΅ΠΉΡΠΈ Π² ΠΏΠΎΠ΄Π΄Π΅ΡΠ΅Π²ΠΎ, ΡΡΠΎΠ±Ρ Π½Π°ΠΉΡΠΈ Π½ΡΠΆΠ½ΡΠ΅ ΡΠ»Π΅ΠΌΠ΅Π½ΡΡ IMG.
ΠΡΡΠ°Π½ΠΎΠ²ΠΈΡΠ΅ ΠΎΡΠ»Π°Π΄ΠΊΡ, Π²ΡΠ±ΡΠ°Π² ΠΡΠ»Π°Π΄ΠΊΠ° > ΠΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ ΠΎΡΠ»Π°Π΄ΠΊΡ ΠΈΠ»ΠΈ Π½Π°ΠΆΠ°Π² ΠΊΠ»Π°Π²ΠΈΡΠΈ SHIFT+F5, Π° Π·Π°ΡΠ΅ΠΌ ΠΈΡΠΏΡΠ°Π²ΡΡΠ΅ ΠΈΡΡ ΠΎΠ΄Π½ΡΠΉ ΠΊΠΎΠ΄.
ΠΠΎΠ»Π½ΡΡ ΡΡΡΠ°Π½ΠΈΡΡ default.html Ρ ΠΈΡΠΏΡΠ°Π²Π»Π΅Π½Π½ΡΠΌ ΠΏΡΠΈΠΌΠ΅ΡΠΎΠΌ ΠΊΠΎΠ΄Π° ΡΠΌ. Π² ΡΠ°Π·Π΄Π΅Π»Π΅ ΠΡΠ»Π°Π΄ΠΊΠ° ΠΏΡΠΈΠΌΠ΅ΡΠ° ΠΊΠΎΠ΄Π° HTML, CSS ΠΈ JavaScript.
ΠΠ½ΡΠ΅ΡΠ°ΠΊΡΠΈΠ²Π½Π°Ρ ΠΎΡΠ»Π°Π΄ΠΊΠ° ΠΈ ΡΠ΅ΠΆΠΈΠΌ ΠΏΡΠΈΠΎΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ
ΠΠΎΠΆΠ½ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΡΠΎΡΠΊΠΈ ΠΎΡΡΠ°Π½ΠΎΠ²Π° ΠΈ ΠΏΠΎΡΠ°Π³ΠΎΠ²ΠΎΠ΅ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΠΊΠΎΠ΄Π° ΠΏΡΠΈ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠΈ ΡΠ°ΠΊΠΈΡ ΡΡΠ΅Π΄ΡΡΠ² ΠΎΡΠ»Π°Π΄ΠΊΠΈ JavaScript, ΠΊΠ°ΠΊ ΠΎΠΊΠ½ΠΎ ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ JavaScript. ΠΡΠ»ΠΈ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ°, ΠΊΠΎΡΠΎΡΠ°Ρ Π²ΡΠΏΠΎΠ»Π½ΡΠ΅ΡΡΡ Π² ΠΎΡΠ»Π°Π΄ΡΠΈΠΊΠ΅, ΠΎΠΊΠ°Π·ΡΠ²Π°Π΅ΡΡΡ Π² ΡΠΎΡΠΊΠ΅ ΠΎΡΡΠ°Π½ΠΎΠ²Π°, ΠΎΡΠ»Π°Π΄ΡΠΈΠΊ Π²ΡΠ΅ΠΌΠ΅Π½Π½ΠΎ ΠΏΡΠΈΠΎΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Π΅Ρ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ. ΠΡΠ»ΠΈ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΠΏΡΠΈΠΎΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½ΠΎ, ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° ΠΏΠ΅ΡΠ΅ΠΊΠ»ΡΡΠ°Π΅ΡΡΡ ΠΈΠ· ΡΠ΅ΠΆΠΈΠΌΠ° Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ Π² ΡΠ΅ΠΆΠΈΠΌ ΠΏΡΠΈΠΎΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ. ΠΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΠΌΠΎΠΆΠ½ΠΎ Π²ΠΎΠ·ΠΎΠ±Π½ΠΎΠ²ΠΈΡΡ Π² Π»ΡΠ±ΠΎΠΉ ΠΌΠΎΠΌΠ΅Π½Ρ.
ΠΠ°ΡΡΡΠΎΠΉΠΊΠ° ΡΠΎΡΠΊΠΈ ΠΎΡΡΠ°Π½ΠΎΠ²Π° ΠΈ ΠΎΡΠ»Π°Π΄ΠΊΠ° ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ
ΠΡΠ±Π΅ΡΠΈΡΠ΅ ΠΡΠ»Π°Π΄ΠΊΠ° > ΠΠ°ΡΠ°ΡΡ ΠΎΡΠ»Π°Π΄ΠΊΡ ΠΈΠ»ΠΈ Π½Π°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ»Π°Π²ΠΈΡΡ F5.
ΠΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π²Ρ ΠΎΠ΄ΠΈΡ Π² ΡΠ΅ΠΆΠΈΠΌ ΠΏΡΠΈΠΎΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ, ΠΊΠΎΠ³Π΄Π° Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ Π΄ΠΎΡΡΠΈΠ³Π°Π΅Ρ ΡΡΠ½ΠΊΡΠΈΠΈ updateImages() ΠΈ ΡΠ΅ΠΊΡΡΠ°Ρ ΡΡΡΠΎΠΊΠ° Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Π²ΡΠ΄Π΅Π»ΡΠ΅ΡΡΡ ΠΆΠ΅Π»ΡΡΠΌ.
ΠΠΎΠΆΠ½ΠΎ ΠΈΠ·ΠΌΠ΅Π½ΠΈΡΡ Π·Π½Π°ΡΠ΅Π½ΠΈΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ , ΡΡΠΎΠ±Ρ Π½Π΅ΠΌΠ΅Π΄Π»Π΅Π½Π½ΠΎ ΠΈΠ·ΠΌΠ΅Π½ΠΈΡΡ ΡΠΎΡΡΠΎΡΠ½ΠΈΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ, Π½Π΅ Π·Π°Π²Π΅ΡΡΠ°Ρ ΡΠ΅ΠΊΡΡΠ΅Π³ΠΎ ΡΠ΅Π°Π½ΡΠ° ΠΎΡΠ»Π°Π΄ΠΊΠΈ.
ΠΠ²Π΅Π΄ΠΈΡΠ΅ Π² ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠ΅ updateImages ΠΈ Π½Π°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ»Π°Π²ΠΈΡΡ ΠΠΠΠ. Π ΠΎΠΊΠ½Π΅ ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ ΠΎΡΠΎΠ±ΡΠ°ΠΆΠ°Π΅ΡΡΡ Π²ΠΈΠ·ΡΠ°Π»ΠΈΠ·Π°ΡΠΎΡ Π΄Π»Ρ Π΄Π°Π½Π½ΠΎΠΉ ΡΡΠ½ΠΊΡΠΈΠΈ.
ΠΡΠ±Π΅ΡΠΈΡΠ΅ ΡΡΠ½ΠΊΡΠΈΡ Π² ΠΎΠΊΠ½Π΅ ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ, ΡΡΠΎΠ±Ρ ΠΎΡΠΎΠ±ΡΠ°Π·ΠΈΡΡ Π΅Π΅ ΡΠ΅Π°Π»ΠΈΠ·Π°ΡΠΈΡ.
ΠΠ° ΡΠ»Π΅Π΄ΡΡΡΠ΅ΠΌ ΡΠΈΡΡΠ½ΠΊΠ΅ ΠΏΠΎΠΊΠ°Π·Π°Π½ΠΎ ΠΎΠΊΠ½ΠΎ ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ Π½Π° ΡΡΠΎΠΌ ΡΡΠ°ΠΏΠ΅.
Π‘ΠΊΠΎΠΏΠΈΡΡΠΉΡΠ΅ ΠΎΠ΄Π½Ρ ΡΡΡΠΎΠΊΡ ΡΡΠ½ΠΊΡΠΈΠΈ ΠΈΠ· ΠΎΠΊΠ½Π° Π²ΡΠ²ΠΎΠ΄Π° Π² ΡΡΡΠΎΠΊΡ Π²Π²ΠΎΠ΄Π° ΠΈ ΠΈΠ·ΠΌΠ΅Π½ΠΈΡΠ΅ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅ ΠΈΠ½Π΄Π΅ΠΊΡΠ° Π½Π° 3:
ΠΠ°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ»Π°Π²ΠΈΡΡ ΠΠΠΠ, ΡΡΠΎΠ±Ρ Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡ ΡΡΡ ΡΡΡΠΎΠΊΡ ΠΊΠΎΠ΄Π°.
ΠΡΠ»ΠΈ ΡΡΠ΅Π±ΡΠ΅ΡΡΡ ΠΏΠΎΡΠ°Π³ΠΎΠ²ΠΎΠ΅ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΠΊΠΎΠ΄Π° ΠΏΠΎ ΠΎΠ΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠ΅, Π½Π°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ»Π°Π²ΠΈΡΡ F11 ΠΈΠ»ΠΈ Π½Π°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ»Π°Π²ΠΈΡΡ F5, ΡΡΠΎΠ±Ρ ΠΏΡΠΎΠ΄ΠΎΠ»ΠΆΠΈΡΡ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ.
Π§ΡΠΎΠ±Ρ Π²Π΅ΡΠ½ΡΡΡΡΡ Π² Visual Studio, Π½Π°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ»Π°Π²ΠΈΡΡ F12 ΠΈΠ»ΠΈ ΡΠΎΡΠ΅ΡΠ°Π½ΠΈΠ΅ ΠΊΠ»Π°Π²ΠΈΡ Alt + Tab.
ΠΠ΄Π½ΠΎΡΡΡΠΎΡΠ½ΡΠΉ ΠΈ ΠΌΠ½ΠΎΠ³ΠΎΡΡΡΠΎΡΠ½ΡΠΉ ΡΠ΅ΠΆΠΈΠΌ Π² ΠΎΠΊΠ½Π΅ ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ JavaScript
Π‘ΡΡΠΎΠΊΠ° Π²Π²ΠΎΠ΄Π° Π² ΠΎΠΊΠ½Π΅ ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ JavaScript ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°Π΅Ρ ΠΎΠ΄Π½ΠΎΡΡΡΠΎΡΠ½ΡΠΉ ΠΈ ΠΌΠ½ΠΎΠ³ΠΎΡΡΡΠΎΡΠ½ΡΠΉ ΡΠ΅ΠΆΠΈΠΌ. ΠΡΠΎΡΠ΅Π΄ΡΡΠ° ΠΈΠ½ΡΠ΅ΡΠ°ΠΊΡΠΈΠ²Π½ΠΎΠΉ ΠΎΡΠ»Π°Π΄ΠΊΠΈ Π² ΡΡΠΎΠΌ ΡΠ°Π·Π΄Π΅Π»Π΅ Π²ΠΊΠ»ΡΡΠ°Π΅Ρ ΠΏΡΠΈΠΌΠ΅ΡΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΡ ΠΎΠ±ΠΎΠΈΡ ΡΠ΅ΠΆΠΈΠΌΠΎΠ². ΠΠΎΠΆΠ½ΠΎ Π½Π°ΠΆΠ°ΡΡ ΡΠΎΡΠ΅ΡΠ°Π½ΠΈΠ΅ ΠΊΠ»Π°Π²ΠΈΡ Ctrl + Alt + M Π΄Π»Ρ ΠΏΠ΅ΡΠ΅ΠΊΠ»ΡΡΠ΅Π½ΠΈΡ ΠΌΠ΅ΠΆΠ΄Ρ ΡΠ΅ΠΆΠΈΠΌΠ°ΠΌΠΈ.
ΠΠ΄Π½ΠΎΡΡΡΠΎΡΠ½ΡΠΉ ΡΠ΅ΠΆΠΈΠΌ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ ΠΏΡΠΎΡΠΌΠ°ΡΡΠΈΠ²Π°ΡΡ ΠΈΡΡΠΎΡΠΈΡ Π²Π²ΠΎΠ΄Π°. ΠΠ»Ρ ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½ΠΈΡ ΠΏΠΎ ΠΈΡΡΠΎΡΠΈΠΈ Π²Π²ΠΎΠ΄Π° ΠΌΠΎΠΆΠ½ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΠΊΠ»Π°Π²ΠΈΡΠΈ ΡΠΎ ΡΡΡΠ΅Π»ΠΊΠΎΠΉ Π²Π²Π΅ΡΡ ΠΈ ΡΡΡΠ΅Π»ΠΊΠΎΠΉ Π²Π½ΠΈΠ·. Π ΠΎΠ΄Π½ΠΎΡΡΡΠΎΡΠ½ΠΎΠΌ ΡΠ΅ΠΆΠΈΠΌΠ΅ ΡΡΡΠΎΠΊΠ° Π²Π²ΠΎΠ΄Π° ΠΎΡΠΈΡΠ°Π΅ΡΡΡ ΠΏΡΠΈ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠΈ ΡΠΊΡΠΈΠΏΡΠΎΠ². Π§ΡΠΎΠ±Ρ Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡ ΡΠΊΡΠΈΠΏΡ Π² ΠΎΠ΄Π½ΠΎΡΡΡΠΎΡΠ½ΠΎΠΌ ΡΠ΅ΠΆΠΈΠΌΠ΅, Π½Π°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ»Π°Π²ΠΈΡΡ ΠΠΠΠ.
Π ΠΌΠ½ΠΎΠ³ΠΎΡΡΡΠΎΡΠ½ΠΎΠΌ ΡΠ΅ΠΆΠΈΠΌΠ΅ ΡΡΡΠΎΠΊΠ° Π²Π²ΠΎΠ΄Π° ΠΏΡΠΈ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠΈ ΡΠΊΡΠΈΠΏΡΠΎΠ² Π½Π΅ ΠΎΡΠΈΡΠ°Π΅ΡΡΡ. ΠΡΠΈ ΠΏΠ΅ΡΠ΅ΠΊΠ»ΡΡΠ΅Π½ΠΈΠΈ ΠΈΠ· ΠΌΠ½ΠΎΠ³ΠΎΡΡΡΠΎΡΠ½ΠΎΠ³ΠΎ ΡΠ΅ΠΆΠΈΠΌΠ° Π² ΠΎΠ΄Π½ΠΎΡΡΡΠΎΡΠ½ΡΠΉ ΠΌΠΎΠΆΠ½ΠΎ ΠΎΡΠΈΡΡΠΈΡΡ ΡΡΡΠΎΠΊΡ Π²Π²ΠΎΠ΄Π°, Π½Π°ΠΆΠ°Π² ΠΊΠ»Π°Π²ΠΈΡΡ ΠΡΠΈΡΡΠΈΡΡ Π²Ρ ΠΎΠ΄Π½ΡΡ ΡΡΡΠΎΠΊΡ (ΠΊΡΠ°ΡΠ½ΡΠΉ Π·Π½Π°ΡΠΎΠΊ «X»). Π§ΡΠΎΠ±Ρ Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡ ΡΠΊΡΠΈΠΏΡ Π² ΠΌΠ½ΠΎΠ³ΠΎΡΡΡΠΎΡΠ½ΠΎΠΌ ΡΠ΅ΠΆΠΈΠΌΠ΅, Π½Π°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ»Π°Π²ΠΈΡΠΈ Ctrl + ΠΠ²ΠΎΠ΄ ΠΈΠ»ΠΈ Π²ΡΠ±Π΅ΡΠΈΡΠ΅ ΡΠΈΠΌΠ²ΠΎΠ» ΡΡΡΠ΅Π»ΠΊΠΈ Π² ΠΏΡΠ°Π²ΠΎΠΌ Π½ΠΈΠΆΠ½Π΅ΠΌ ΡΠ³Π»Ρ ΠΎΠΊΠ½Π°.
ΠΠ΅ΡΠ΅ΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡΠ° Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ ΡΠΊΡΠΈΠΏΡΠ°
ΠΠ° ΡΠ»Π΅Π΄ΡΡΡΠ΅ΠΌ ΡΠΈΡΡΠ½ΠΊΠ΅ ΠΏΠΎΠΊΠ°Π·Π°Π½ ΡΠΏΠΈΡΠΎΠΊ «Π¦Π΅Π»Ρ» Π² ΠΎΠΊΠ½Π΅ ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ JavaScript.
ΠΡΠ»Π°Π΄ΠΊΠ° ΠΏΡΠΎΠ΅ΠΊΡΠΎΠ² JavaScript Ρ ΠΏΠΎΠΌΠΎΡΡΡ VS Code & Chrome Debugger
ΠΡΠ»Π°Π΄ΠΊΠ° JavaScript Π½Π΅ ΡΠ°ΠΌΡΠΉ ΠΈΠ½ΡΠ΅ΡΠ΅ΡΠ½ΡΠΉ Π°ΡΠΏΠ΅ΠΊΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π½Π° JavaScript, Π½ΠΎ ΡΡΠΎ ΠΆΠΈΠ·Π½Π΅Π½Π½ΠΎ Π²Π°ΠΆΠ½ΡΠΉ Π½Π°Π²ΡΠΊ. Π ΡΡΠΎΠΉ ΡΡΠ°ΡΡΠ΅ ΡΠ°ΡΡΠΌΠ°ΡΡΠΈΠ²Π°ΡΡΡΡ Π΄Π²Π° ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΠ°, ΠΊΠΎΡΠΎΡΡΠ΅ ΠΏΠΎΠΌΠΎΠ³ΡΡ Π²Π°ΠΌ ΠΎΡΠ»Π°Π΄ΠΈΡΡ JavaScript ΠΊΠ°ΠΊ ΠΏΡΠΎΡΠ΅ΡΡΠΈΠΎΠ½Π°Π».
ΠΡΠ΅Π΄ΡΡΠ°Π²ΡΡΠ΅ Π½Π° ΠΌΠ³Π½ΠΎΠ²Π΅Π½ΠΈΠ΅, ΡΡΠΎ ΡΡΠ½ΠΊΡΠΈΡ console.log() Π½Π΅ ΡΡΡΠ΅ΡΡΠ²ΡΠ΅Ρ Π² JavaScript. Π― ΡΠ²Π΅ΡΠ΅Π½, ΡΡΠΎ ΠΏΠ΅ΡΠ²ΡΠΉ Π²ΠΎΠΏΡΠΎΡ, ΠΊΠΎΡΠΎΡΡΠΉ Π²Ρ ΡΠ΅Π±Π΅ Π·Π°Π΄Π°Π΄ΠΈΡΠ΅, Π±ΡΠ΄Π΅Ρ: Β«ΠΠ°ΠΊ Ρ ΡΠΌΠΎΠ³Ρ ΡΠ±Π΅Π΄ΠΈΡΡΡΡ, ΡΡΠΎ ΠΌΠΎΠΉ ΠΊΠΎΠ΄ ΡΠ°Π±ΠΎΡΠ°Π΅Ρ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΠΎ?Β»
ΠΡΠ²Π΅Ρ Π·Π°ΠΊΠ»ΡΡΠ°Π΅ΡΡΡ Π² ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠΈ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΠΎΠ² ΠΎΡΠ»Π°Π΄ΠΊΠΈ. Π ΡΠ΅ΡΠ΅Π½ΠΈΠ΅ Π΄ΠΎΠ»Π³ΠΎΠ³ΠΎ Π²ΡΠ΅ΠΌΠ΅Π½ΠΈ Π±ΠΎΠ»ΡΡΠΈΠ½ΡΡΠ²ΠΎ ΡΠ°Π·ΡΠ°Π±ΠΎΡΡΠΈΠΊΠΎΠ², Π²ΠΊΠ»ΡΡΠ°Ρ ΠΌΠ΅Π½Ρ, ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π»ΠΈ console.log Π΄Π»Ρ ΠΎΡΠ»Π°Π΄ΠΊΠΈ Π½Π΅ΡΠ°Π±ΠΎΡΠ°ΡΡΠ΅Π³ΠΎ ΠΊΠΎΠ΄Π°. ΠΡΠΎ Π±ΡΡΡΡΡΠΉ ΠΈ ΠΏΡΠΎΡΡΠΎΠΉ Π² ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠΈ. Π’Π΅ΠΌ Π½Π΅ ΠΌΠ΅Π½Π΅Π΅, ΠΈΠ½ΠΎΠ³Π΄Π° Π²Π΅ΡΠΈ ΠΌΠΎΠ³ΡΡ ΡΡΠ°Π½ΠΎΠ²ΠΈΡΡΡΡ ΠΏΡΠΈΠ²Π΅ΡΠ΅Π΄Π»ΠΈΠ²ΡΠΌΠΈ, Π΅ΡΠ»ΠΈ Π²Ρ Π½Π΅ Π·Π½Π°Π΅ΡΠ΅, Π³Π΄Π΅ ΠΈ ΡΡΠΎ ΡΠ²Π»ΡΠ΅ΡΡΡ ΠΏΡΠΈΡΠΈΠ½ΠΎΠΉ ΠΎΡΠΈΠ±ΠΊΠΈ. Π§Π°ΡΡΠΎ Π²Ρ ΠΎΠ±Π½Π°ΡΡΠΆΠΈΠ²Π°Π΅ΡΠ΅, ΡΡΠΎ ΡΠ°ΡΡΡΠ°Π²Π»ΡΠ΅ΡΠ΅ Π»ΠΎΠ²ΡΡΠΊΠΈ console.log Π²ΡΠ΅ΠΌΡ ΠΊΠΎΠ΄Ρ, ΡΡΠΎΠ±Ρ ΡΠ²ΠΈΠ΄Π΅ΡΡ, ΠΊΠ°ΠΊΠΎΠΉ ΠΈΠ· Π½ΠΈΡ Π²ΡΡΠ²ΠΈΡ Π²ΠΈΠ½ΠΎΠ²Π½ΠΈΠΊΠ°.
ΠΡΠ΅Π΄ΠΏΠΎΡΡΠ»ΠΊΠΈ
Π’Π΅ΠΏΠ΅ΡΡ ΠΌΡ Π³ΠΎΡΠΎΠ²Ρ Π½Π°ΡΡΠΈΡΡΡΡ ΠΎΡΠ»Π°ΠΆΠΈΠ²Π°ΡΡ ΠΏΡΠΎΠ΅ΠΊΡ JavaScript Π² VS Code.
ΠΡΠ»Π°Π΄ΠΊΠ° JavaScript Π² VS Code
ΠΠΎΠ΄ Π΄ΠΎΠ²ΠΎΠ»ΡΠ½ΠΎ ΠΏΡΠΎΡΡ, ΠΈ Π΅ΡΠ»ΠΈ Ρ Π²Π°Ρ Π΄ΠΎΡΡΠ°ΡΠΎΡΠ½ΠΎ ΠΎΠΏΡΡΠ° Π² ΠΊΠΎΠ΄ΠΈΡΠΎΠ²Π°Π½ΠΈΠΈ, Π²Ρ ΠΌΠΎΠΆΠ΅ΡΠ΅ Π·Π°ΠΌΠ΅ΡΠΈΡΡ, ΡΡΠΎ Π² Π½Π΅ΠΌ Π΅ΡΡΡ ΠΏΠ°ΡΠ° ΠΎΡΠΈΠ±ΠΎΠΊ. ΠΡΠ»ΠΈ Π²Ρ Π·Π°ΠΌΠ΅ΡΠΈΠ»ΠΈ ΠΈΡ , ΠΏΠΎΠΆΠ°Π»ΡΠΉΡΡΠ°, ΠΈΠ³Π½ΠΎΡΠΈΡΡΠΉΡΠ΅ ΠΈΡ . ΠΡΠ»ΠΈ Π½Π΅Ρ, ΠΎΡΠ»ΠΈΡΠ½ΠΎ. ΠΠ°Π²Π°ΠΉΡΠ΅ Π΄ΠΎΠ±Π°Π²ΠΈΠΌ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ ΡΡΡΠΎΠΊ Π²Π½ΠΈΠ·Ρ, ΡΡΠΎΠ±Ρ Π²ΡΡΡΠ½ΡΡ ΠΏΡΠΎΠ²Π΅ΡΠΈΡΡ ΠΊΠΎΠ΄:
ΠΠΈΠ΄ΠΈΡΠ΅ ΠΊΡΠ°ΡΠ½ΡΠ΅ ΡΠΎΡΠΊΠΈ Π½Π° ΡΡΠΎΡΠΎΠ½Π΅? ΠΡΠΎ ΡΠΎΡΠΊΠΈ ΠΎΡΡΠ°Π½ΠΎΠ²Π°. Π’ΠΎΡΠΊΠ° ΠΎΡΡΠ°Π½ΠΎΠ²Π° β ΡΡΠΎ ΠΏΡΠΎΡΡΠΎ Π²ΠΈΠ·ΡΠ°Π»ΡΠ½Π°Ρ ΠΈΠ½Π΄ΠΈΠΊΠ°ΡΠΈΡ, ΡΠΊΠ°Π·ΡΠ²Π°ΡΡΠ°Ρ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΡ ΠΎΡΠ»Π°Π΄ΡΠΈΠΊΠ°, Π³Π΄Π΅ ΠΏΡΠΈΠΎΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅. ΠΠ°ΡΠ΅ΠΌ Π½Π° ΠΏΠ°Π½Π΅Π»ΠΈ Π΄Π΅ΠΉΡΡΠ²ΠΈΠΉ Π½Π°ΠΆΠΌΠΈΡΠ΅ ΠΊΠ½ΠΎΠΏΠΊΡ ΠΎΡΠ»Π°Π΄ΠΊΠΈ (Π·Π½Π°ΡΠΎΠΊ Ρ Π½Π°Π΄ΠΏΠΈΡΡΡ Β«ΠΡΠΈΠ±ΠΊΠΈ Π½Π΅ ΡΠ°Π·ΡΠ΅ΡΠ΅Π½ΡΒ»).
ΠΡΠΈΠΌΠ΅ΡΠ°Π½ΠΈΠ΅. Π Π·Π°Π²ΠΈΡΠΈΠΌΠΎΡΡΠΈ ΠΎΡ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΎΠ½Π½ΠΎΠΉ ΡΠΈΡΡΠ΅ΠΌΡ Π²Π°ΠΌ ΠΌΠΎΠΆΠ΅Ρ ΠΏΠΎΡΡΠ΅Π±ΠΎΠ²Π°ΡΡΡΡ Π·Π°ΠΌΠ΅Π½ΠΈΡΡ Π΄Π²ΠΎΠΉΠ½ΡΡ ΠΎΠ±ΡΠ°ΡΠ½ΡΡ ΠΊΠΎΡΡΡ ΡΠ΅ΡΡΡ ( \\ ) Π½Π° ΠΎΠ΄Π½Ρ ΠΏΡΡΠΌΡΡ ΠΊΠΎΡΡΡ ΡΠ΅ΡΡΡ ( / ).
ΠΡΠΏΠΎΠ»ΡΠ·ΡΠΉΡΠ΅ Π»ΡΠ±ΠΎΠΉ ΠΌΠ΅ΡΠΎΠ΄, ΠΊΠΎΡΠΎΡΡΠΉ Π²Π°ΠΌ Π½ΡΠ°Π²ΠΈΡΡΡ, ΠΈ Π½Π°Π±Π»ΡΠ΄Π°ΠΉΡΠ΅ Π·Π° ΠΏΡΠΎΡΠ΅ΡΡΠΎΠΌ ΠΎΡΠ»Π°Π΄ΠΊΠΈ Π² Π΄Π΅ΠΉΡΡΠ²ΠΈΠΈ:
Π ΡΠ΄ Π²Π΅ΡΠ΅ΠΉ ΠΏΡΠΎΠΈΡΡ ΠΎΠ΄ΠΈΡ Π² Π±ΡΡΡΡΠΎΠΉ ΠΏΠΎΡΠ»Π΅Π΄ΠΎΠ²Π°ΡΠ΅Π»ΡΠ½ΠΎΡΡΠΈ, ΠΊΠΎΠ³Π΄Π° Π²Ρ Π½Π°ΠΆΠΈΠΌΠ°Π΅ΡΠ΅ ΠΊΠ½ΠΎΠΏΠΊΡ ΠΎΡΠ»Π°Π΄ΠΊΠΈ. ΠΠΎ-ΠΏΠ΅ΡΠ²ΡΡ , Π΅ΡΡΡ ΠΏΠ°Π½Π΅Π»Ρ ΠΈΠ½ΡΡΡΡΠΌΠ΅Π½ΡΠΎΠ², ΠΊΠΎΡΠΎΡΠ°Ρ ΠΏΠΎΡΠ²Π»ΡΠ΅ΡΡΡ Π² Π²Π΅ΡΡ Π½Π΅ΠΉ ΡΠ°ΡΡΠΈ ΡΠ΅Π΄Π°ΠΊΡΠΎΡΠ°. ΠΠΌΠ΅Π΅Ρ ΡΠ»Π΅Π΄ΡΡΡΠΈΠ΅ ΡΠ»Π΅ΠΌΠ΅Π½ΡΡ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΡ:
ΠΡ ΡΠ°ΠΊΠΆΠ΅ ΠΌΠΎΠΆΠ΅ΡΠ΅ ΠΏΡΠΎΠ²Π΅ΡΠΈΡΡ Π²ΡΠ΅ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΠ΅, Π½Π°Ρ ΠΎΠ΄ΡΡΠΈΠ΅ΡΡ Π² ΠΎΠ±Π»Π°ΡΡΠΈ Π΄Π΅ΠΉΡΡΠ²ΠΈΡ, Π² ΡΠ°Π·Π΄Π΅Π»Π΅ Β« ΠΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΠ΅ Β».
Π ΠΏΠΎΠΊΠ° ΠΏΡΠΎΡΡΠΎ Π·Π°Π²Π΅ΡΡΠΈΡΠ΅ ΡΠ΅Π°Π½Ρ ΠΎΡΠ»Π°Π΄ΠΊΠΈ. ΠΡ ΠΈΡΠΏΡΠ°Π²ΠΈΠΌ ΠΈΡ Π² ΡΠ»Π΅Π΄ΡΡΡΠ΅ΠΌ ΡΠ°Π·Π΄Π΅Π»Π΅.
ΠΡΠ»Π°Π΄ΠΊΠ° ΡΠ΅ΡΡΠΎΠ² Ρ Mocha
ΠΡ ΡΠ°ΠΊΠΆΠ΅ ΠΌΠΎΠΆΠ΅ΡΠ΅ Π·Π°ΠΏΡΡΡΠΈΡΡ npm test Π΄Π»Ρ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ ΡΠ΅ΡΡΠΎΠ². ΠΡ Π΄ΠΎΠ»ΠΆΠ½Ρ ΠΏΠΎΠ»ΡΡΠΈΡΡ ΡΠ»Π΅Π΄ΡΡΡΠΈΠΉ Π²ΡΠ²ΠΎΠ΄:
ΠΡΠ΅ ΡΠ΅ΡΡΡ Π½Π΅ ΠΏΡΠΎΠΉΠ΄Π΅Π½Ρ. Π§ΡΠΎΠ±Ρ Π²ΡΡΡΠ½ΠΈΡΡ ΠΏΡΠΎΠ±Π»Π΅ΠΌΡ, ΠΌΡ ΡΠΎΠ±ΠΈΡΠ°Π΅ΠΌΡΡ Π·Π°ΠΏΡΡΡΠΈΡΡ ΡΠ΅ΡΡΡ Π² ΡΠ΅ΠΆΠΈΠΌΠ΅ ΠΎΡΠ»Π°Π΄ΠΊΠΈ. ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ Π½Π°ΠΌ Π½ΡΠΆΠ½Π° Π½ΠΎΠ²Π°Ρ ΠΊΠΎΠ½ΡΠΈΠ³ΡΡΠ°ΡΠΈΡ. ΠΠ΅ΡΠ΅ΠΉΠ΄ΠΈΡΠ΅ Π½Π° ΠΏΠ°Π½Π΅Π»Ρ ΠΎΡΠ»Π°Π΄ΠΊΠΈ ΠΈ ΡΠ΅Π»ΠΊΠ½ΠΈΡΠ΅ ΡΠ°ΡΠΊΡΡΠ²Π°ΡΡΠΈΠΉΡΡ ΡΠΏΠΈΡΠΎΠΊ, ΡΡΠΎΠ±Ρ ΠΏΠΎΠ»ΡΡΠΈΡΡ Π΄ΠΎΡΡΡΠΏ ΠΊ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΡ Β« Add Configuration :
launch.json ΡΠ°ΠΉΠ» launch.json Ρ Π²ΡΠΏΠ»ΡΠ²Π°ΡΡΠΈΠΌ ΡΠΏΠΈΡΠΊΠΎΠΌ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΈΡ ΠΊΠΎΠ½ΡΠΈΠ³ΡΡΠ°ΡΠΈΠΉ Π½Π° Π²ΡΠ±ΠΎΡ.
Debugging
One of the key features of Visual Studio Code is its great debugging support. VS Code’s built-in debugger helps accelerate your edit, compile and debug loop.
Debugger extensions
VS Code has built-in debugging support for the Node.js runtime and can debug JavaScript, TypeScript, or any other language that gets transpiled to JavaScript.
For debugging other languages and runtimes (including PHP, Ruby, Go, C#, Python, C++, PowerShell and many others), look for Debuggers extensions in the VS Code Marketplace or select Install Additional Debuggers in the top-level Run menu.
Below are several popular extensions which include debugging support:
Tip: The extensions shown above are dynamically queried. Select an extension tile above to read the description and reviews to decide which extension is best for you.
Start debugging
The following documentation is based on the built-in Node.js debugger, but most of the concepts and features are applicable to other debuggers as well.
It is helpful to first create a sample Node.js application before reading about debugging. You can follow the Node.js walkthrough to install Node.js and create a simple «Hello World» JavaScript application ( app.js ). Once you have a simple application set up, this page will take you through VS Code debugging features.
Run view
The Run view displays all information related to running and debugging and has a top bar with debugging commands and configuration settings.
If running and debugging is not yet configured (no launch.json has been created), VS Code shows the Run start view.
Run menu
The top-level Run menu has the most common run and debug commands:
Launch configurations
To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and VS Code will try to run your currently active file.
To create a launch.json file, click the create a launch.json file link in the Run start view.
VS Code will try to automatically detect your debug environment, but if this fails, you will have to choose it manually:
Here is the launch configuration generated for Node.js debugging:
Note: You can debug a simple application even if you don’t have a folder open in VS Code, but it is not possible to manage launch configurations and set up advanced debugging. The VS Code Status Bar is purple if you do not have a folder open.
Note that the attributes available in launch configurations vary from debugger to debugger. You can use IntelliSense suggestions ( βSpace (Windows, Linux Ctrl+Space ) ) to find out which attributes exist for a specific debugger. Hover help is also available for all attributes.
Do not assume that an attribute that is available for one debugger automatically works for other debuggers too. If you see green squiggles in your launch configuration, hover over them to learn what the problem is and try to fix them before launching a debug session.
Review all automatically generated values and make sure that they make sense for your project and debugging environment.
Launch versus attach configurations
In VS Code, there are two core debugging modes, Launch and Attach, which handle two different workflows and segments of developers. Depending on your workflow, it can be confusing to know what type of configuration is appropriate for your project.
If you come from a browser Developer Tools background, you might not be used to «launching from your tool,» since your browser instance is already open. When you open DevTools, you are simply attaching DevTools to your open browser tab. On the other hand, if you come from a server or desktop background, it’s quite normal to have your editor launch your process for you, and your editor automatically attaches its debugger to the newly launched process.
The best way to explain the difference between launch and attach is to think of a launch configuration as a recipe for how to start your app in debug mode before VS Code attaches to it, while an attach configuration is a recipe for how to connect VS Code’s debugger to an app or process that’s already running.
VS Code debuggers typically support launching a program in debug mode or attaching to an already running program in debug mode. Depending on the request ( attach or launch ), different attributes are required, and VS Code’s launch.json validation and suggestions should help with that.
Add a new configuration
VS Code also supports compound launch configurations for starting multiple configurations at the same time; for more details, please read this section.
As soon as a debugging session starts, the DEBUG CONSOLE panel is displayed and shows debugging output, and the Status Bar changes color (orange for default color themes):
In addition, the debug status appears in the Status Bar showing the active debug configuration. By selecting the debug status, a user can change the active launch configuration and start debugging without needing to open the Run view.
Debug actions
Once a debug session starts, the Debug toolbar will appear on the top of the editor.
Run mode
In addition to debugging a program, VS Code supports running the program. The Debug: Run (Start Without Debugging) action is triggered with βF5 (Windows, Linux Ctrl+F5 ) and uses the currently selected launch configuration. Many of the launch configuration attributes are supported in ‘Run’ mode. VS Code maintains a debug session while the program is running, and pressing the Stop button terminates the program.
Tip: The Run action is always available, but not all debugger extensions support ‘Run’. In this case, ‘Run’ will be the same as ‘Debug’.
Breakpoints
Breakpoints can be toggled by clicking on the editor margin or using F9 on the current line. Finer breakpoint control (enable/disable/reapply) can be done in the Run view’s BREAKPOINTS section.
The Reapply All Breakpoints command sets all breakpoints again to their original location. This is helpful if your debug environment is «lazy» and «misplaces» breakpoints in source code that has not yet been executed.
Optionally breakpoints can be shown in the editor’s overview ruler by enabling the setting debug.showBreakpointsInOverviewRuler :
Logpoints
A Logpoint is a variant of a breakpoint that does not «break» into the debugger but instead logs a message to the console. Logpoints are especially useful for injecting logging while debugging production servers that cannot be paused or stopped.
A Logpoint is represented by a «diamond» shaped icon. Log messages are plain text but can include expressions to be evaluated within curly braces (‘<>‘).
Just like regular breakpoints, Logpoints can be enabled or disabled and can also be controlled by a condition and/or hit count.
Note: Logpoints are supported by VS Code’s built-in Node.js debugger, but can be implemented by other debug extensions. The Python and Java extensions, for example, support Logpoints.
Data inspection
Variables can be inspected in the VARIABLES section of the Run view or by hovering over their source in the editor. Variable values and expression evaluation are relative to the selected stack frame in the CALL STACK section.
Variable values can be modified with the Set Value action from the variable’s context menu. Additionally, you can use the Copy Value action to copy the variable’s value, or Copy as Expression action to copy an expression to access the variable.
Variables and expressions can also be evaluated and watched in the Run view’s WATCH section.
Variable names and values can be filtered by typing while the focus is on the VARIABLES section
Launch.json attributes
There are many launch.json attributes to help support different debuggers and debugging scenarios. As mentioned above, you can use IntelliSense ( βSpace (Windows, Linux Ctrl+Space ) ) to see the list of available attributes once you have specified a value for the type attribute.
The following attributes are mandatory for every launch configuration:
Here are some optional attributes available to all launch configurations:
Many debuggers support some of the following attributes:
Variable substitution
Platform-specific properties
Launch.json supports defining values (for example, arguments to be passed to the program) that depend on the operating system where the debugger is running. To do so, put a platform-specific literal into the launch.json file and specify the corresponding properties inside that literal.
Below is an example that passes «args» to the program differently on Windows:
Valid operating properties are «windows» for Windows, «linux» for Linux and «osx» for macOS. Properties defined in an operating system specific scope override properties defined in the global scope.
Please note that the type property cannot be placed inside a platform-specific section, because type indirectly determines the platform in remote debugging scenarios, and that would result in a cyclic dependency.
In the example below debugging the program always stops on entry except on macOS:
Global launch configuration
VS Code supports adding a «launch» object inside your User settings. This «launch» configuration will then be shared across your workspaces. For example:
Advanced breakpoint topics
Conditional breakpoints
A powerful VS Code debugging feature is the ability to set conditions based on expressions, hit counts, or a combination of both.
You can add a condition and/or hit count when creating a source breakpoint (with the Add Conditional Breakpoint action) or when modifying an existing one (with the Edit Condition action). In both cases, an inline text box with a dropdown menu opens where you can enter expressions:
Condition and hit count editing support is also supported for function and exception breakpoints. You can initiate condition editing from the context menu, or the new inline Edit Condition action.
An example of condition editing in the BREAKPOINTS view:
If a debugger does not support conditional breakpoints, the Add Conditional Breakpoint and Edit Condition actions will be missing.
Inline breakpoints
Inline breakpoints will only be hit when the execution reaches the column associated with the inline breakpoint. This is particularly useful when debugging minified code which contains multiple statements in a single line.
An inline breakpoint can be set using β§F9 (Windows, Linux Shift+F9 ) or through the context menu during a debug session. Inline breakpoints are shown inline in the editor.
Inline breakpoints can also have conditions. Editing multiple breakpoints on a line is possible through the context menu in the editor’s left margin.
Function breakpoints
Instead of placing breakpoints directly in source code, a debugger can support creating breakpoints by specifying a function name. This is useful in situations where source is not available but a function name is known.
A function breakpoint is created by pressing the + button in the BREAKPOINTS section header and entering the function name. Function breakpoints are shown with a red triangle in the BREAKPOINTS section.
Data breakpoints
If a debugger supports data breakpoints they can be set from the VARIABLES view and will get hit when the value of the underlying variable changes. Data breakpoints are shown with a red hexagon in the BREAKPOINTS section.
Debug Console REPL
Note: You must be in a running debug session to use the Debug Console REPL.
Redirect input/output to/from the debug target
Redirecting input/output is debugger/runtime specific, so VS Code does not have a built-in solution that works for all debuggers.
Here are two approaches you might want to consider:
Launch the program to debug («debug target») manually in a terminal or command prompt and redirect input/output as needed. Make sure to pass the appropriate command line options to the debug target so that a debugger can attach to it. Create and run an «attach» debug configuration that attaches to the debug target.
If the debugger extension you are using can run the debug target in VS Code’s Integrated Terminal (or an external terminal), you can try to pass the shell redirect syntax (for example » «) as arguments.
Here’s an example launch.json configuration:
This approach requires that the » preLaunchTask can be specified that is run before the individual debug sessions are started.
Compound launch configurations are displayed in the launch configuration dropdown menu.
Remote debugging
VS Code does not itself support remote debugging: this is a feature of the debug extension you are using, and you should consult the extension’s page in the Marketplace for support and details.
There is, however, one exception: the Node.js debugger included in VS Code supports remote debugging. See the Node.js Debugging topic to learn how to configure this.
Automatically open a URI when debugging a server program
Developing a web program typically requires opening a specific URL in a web browser in order to hit the server code in the debugger. VS Code has a built-in feature «serverReadyAction» to automate this task.
Here is an example of a simple Node.js Express application:
This application first installs a «Hello World» handler for the «/» URL and then starts to listen for HTTP connections on port 3000. The port is announced in the Debug Console and typically the developer would now type http://localhost:3000 into their browser application.
The serverReadyAction feature makes it possible to add a structured property serverReadyAction to any launch config and select an «action» to be performed:
Here the pattern property describes the regular expression for matching the program’s output string that announces the port. The pattern for the port number is put into parenthesis so that it is available as a regular expression capture group. In this example, we are extracting only the port number, but it is also possible to extract a full URI.
The uriFormat property describes how the port number is turned into a URI. The first %s is substituted by the first capture group of the matching pattern.
The resulting URI is then opened outside of VS Code («externally») with the standard application configured for the URI’s scheme.
Trigger Debugging via Edge or Chrome
To simplify things a bit, most properties are optional and we use the following fallback values:
Triggering an Arbitrary Launch Config
Here the serverReadyAction feature in action:
Next steps
To learn about VS Code’s Node.js debugging support, take a look at:
To see tutorials on the basics of Node.js debugging, check out these videos:
To learn about debugging support for other programming languages via VS Code extensions:
To learn about VS Code’s task running support, go to:
To write your own debugger extension, visit: