| 1 | --- |
| 2 | layout: default |
| 3 | --- |
| 4 | |
| 5 | # Simple Vue SFC Runner |
| 6 | |
| 7 | <!-- eslint-skip --> |
| 8 | |
| 9 | ```vue {monaco-run} |
| 10 | <script setup> |
| 11 | import { computed, ref } from 'vue' |
| 12 | const counter = ref(1) |
| 13 | const doubled = computed(() => counter.value * 2) |
| 14 | function inc() { counter.value++ } |
| 15 | </script> |
| 16 | |
| 17 | <template> |
| 18 | <div class="select-none text-lg flex gap-4 items-center"> |
| 19 | <span class="text-gray text-lg"> |
| 20 | <span class="text-orange">{{ counter }}</span> |
| 21 | * 2 = |
| 22 | <span class="text-green">{{ doubled }}</span> |
| 23 | </span> |
| 24 | <button class="border border-main p2 rounded" @click="inc">+1</button> |
| 25 | <button class="border border-main p2 rounded" @click="counter -= 1">-1</button> |
| 26 | </div> |
| 27 | </template> |
| 28 | ``` |
| 29 | |
| 30 | --- |
| 31 | |
| 32 | This is a demo to prove the extensibility of Slidev Code Runners. |
| 33 | |
| 34 | Refer to `./setup/monaco-runner.ts` for the implementation. |
| 35 | |
| 36 | Note that there is a lot of edge cases that this demo is not handling. Extra work is needed to make it production ready. |
| 37 |