|
| 1 | +# Vue `script setup` snippets |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | +<img alt="logo" src="/img/logo.png" width="200" height="200"/> |
| 7 | + |
| 8 | +In VSCode search for **`vue-script-setup-snippets`** and install it. |
| 9 | + |
| 10 | +## Features |
| 11 | + |
| 12 | +This extension adds snippets for [Vue 3 script setup](https://vuejs.org/api/composition-api-setup.html) syntax. |
| 13 | + |
| 14 | + |
| 15 | +## Snippets |
| 16 | + |
| 17 | +>Note: `$1`, `$2`, etc. are placeholders. Press `Tab` to jump between placeholders. |
| 18 | +
|
| 19 | +| Snippet | Purpose | |
| 20 | +| ------- | ------- | |
| 21 | +| `s-file` | Vue 3 script setup file | |
| 22 | +| `s-file-ts` | Vue 3 script setup file with typescript | |
| 23 | +|`s-ref` | `const $1 = ref($2)` | |
| 24 | +|`s-ref-ts` | `const $1: Ref<$2> = ref($3)` | |
| 25 | +|`s-props` | `const $1 = defineProps<$2>()` | |
| 26 | +|`s-props-ts` | `const $1 = defineProps<$2>()` | |
| 27 | +|`s-emit` | `const $1 = defineEmit<$2>()` | |
| 28 | +|`s-emit-ts` | `const $1 = defineEmit<$2>()` | |
| 29 | +|`s-context` | `const $1 = defineContext<$2>()` | |
| 30 | +|`s-context-ts` | `const $1 = defineContext<$2>()` | |
| 31 | +|`s-computed` | `const $1 = computed(() => $2)` | |
| 32 | +|`s-computed-ts` | `const $1: Ref<$2> = computed(() => $3)` | |
| 33 | +|`s-watch` | `watch($1, ($2) => { $3 })` | |
| 34 | +|`s-watch-getter` | `watch(()=>$1, ($2) => { $3 })` | |
| 35 | +|`s-ronly` | `const $1 = readonly($2)` | |
| 36 | +|`s-ronly-ts` | `const $1: Readonly<Ref<$2>> = readonly($3)` | |
| 37 | +|`s-weffect` | `watchEffect(() => { $1 })` | |
| 38 | +|`s-wpeffect` | `watchPostEffect(() => { $1 })` | |
| 39 | +|`s-wseffect` | `watchSyncEffect(() => { $1 })` | |
| 40 | +|`s-prvd` | `const $1 = provide($2, $3)` | |
| 41 | +|`s-prvd-ts` | `const $1: InjectionKey<$2> = provide($3, $4)` | |
| 42 | +|`s-inject` | `const $1 = inject($2, $3)` | |
| 43 | +|`s-inject-ts` | `const $1: Ref<$2> = inject($3, $4)` | |
| 44 | +|`s-mnt` | `onMounted(() => { $1 })` | |
| 45 | +|`s-upd` | `onUpdated(() => { $1 })` | |
| 46 | +|`s-umnt` | `onUnmounted(() => { $1 })` | |
| 47 | +|`s-bmnt` | `onBeforeMount(() => { $1 })` | |
| 48 | +|`s-bupd` | `onBeforeUpdate(() => { $1 })` | |
| 49 | +|`s-bumnt` | `onBeforeUnmount(() => { $1 })` | |
| 50 | +|`s-err` | `onErrorCaptured(() => { $1 })` | |
| 51 | +|`s-rtrk` | `onRenderTracked(() => { $1 })` | |
| 52 | +|`s-rtrg` | `onRenderTriggered(() => { $1 })` | |
| 53 | +|`s-act` | `onActivated(() => { $1 })` | |
| 54 | +|`s-dact` | `onDeactivated(() => { $1 })` | |
| 55 | +|`s-spf` | `onServerPrefetch(() => { $1 })` | |
| 56 | +|`s-isref` | `isRef($1)` | |
| 57 | +|`s-unref` | `unref($1)` | |
| 58 | +|`s-toref` | `toRef($1, $2)` | |
| 59 | +|`s-torefs` | `toRefs($1)` | |
| 60 | +|`s-isprx` | `isProxy($1)` | |
| 61 | +|`s-isrct` | `isReactive($1)` | |
| 62 | +|`s-isrdo` | `isReadonly($1)` | |
| 63 | +|`s-ssref` | `shallowRef($1)` | |
| 64 | +|`s-trref` | `triggerRef($1)` | |
| 65 | +|`s-csref` | `customRef(($1) => { return { get: () => $2, set: ($3) => $4 } })` | |
| 66 | +|`s-ssrct` | `shallowReactive($1)` | |
| 67 | +|`s-ssrdo` | `shallowReadonly($1)` | |
| 68 | +|`s-toraw` | `toRaw($1)` | |
| 69 | +|`s-mkraw` | `markRaw($1)` | |
| 70 | +|`s-efscp` | `effectScope(($1) => { $2 })` | |
| 71 | +|`s-curscp` | `getCurrentScope()` | |
| 72 | +|`s-ondscp` | `onScopeDispose(() => { $1 })` | |
0 commit comments