返回 slidev
editor-monaco-run.md
根目录 / skills / slidev / references / editor-monaco-run.md
1 ---
2 name: monaco-run
3 description: Run code directly in the editor and see results
4 ---
5
6 # Monaco Runner
7
8 Run code directly in the editor and see results.
9
10 ## Basic Usage
11
12 ````md
13 ```ts {monaco-run}
14 function distance(x: number, y: number) {
15 return Math.sqrt(x ** 2 + y ** 2)
16 }
17 console.log(distance(3, 4))
18 ```
19 ````
20
21 Shows a "Run" button and displays output below the code.
22
23 ## Disable Auto-run
24
25 ````md
26 ```ts {monaco-run} {autorun:false}
27 console.log('Click the play button to run me')
28 ```
29 ````
30
31 ## Show Output on Click
32
33 ````md
34 ```ts {monaco-run} {showOutputAt:'+1'}
35 console.log('Shown after 1 click')
36 ```
37 ````
38
39 ## Supported Languages
40
41 - JavaScript
42 - TypeScript
43
44 For other languages, configure custom code runners in `/custom/config-code-runners`.
45
45 lines MARKDOWN