├── .gitattributes
├── .gitignore
├── .vscode
├── launch.json
└── settings.json
├── .vscodeignore
├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── assets
└── icon.png
├── deno.json
├── deno.lock
├── package-lock.json
├── package.json
├── src
├── app.ts
├── deps.ts
├── docgen
│ ├── snippets.ts
│ └── table-html.ts
├── models
│ └── app.ts
├── snippets
│ ├── app.ts
│ ├── nuxt
│ │ ├── app.ts
│ │ ├── script.ts
│ │ └── template.ts
│ ├── pinia
│ │ ├── app.ts
│ │ └── script.ts
│ ├── vue-macros
│ │ ├── app.ts
│ │ └── script.ts
│ ├── vue-router
│ │ ├── app.ts
│ │ ├── script.ts
│ │ └── template.ts
│ ├── vue
│ │ ├── app.ts
│ │ ├── code-snippets.ts
│ │ ├── script.ts
│ │ ├── style.ts
│ │ ├── template.ts
│ │ └── vue.ts
│ └── vueuse
│ │ ├── app.ts
│ │ └── js.ts
└── utils
│ ├── general.ts
│ └── snippets.ts
└── vsc-extension-quickstart.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Set default behavior to automatically normalize line endings.
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | *.vsix
3 | dist
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | // A launch configuration that launches the extension inside a new window
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | {
6 | "version": "0.2.0",
7 | "configurations": [
8 | {
9 | "name": "Extension",
10 | "type": "extensionHost",
11 | "request": "launch",
12 | "args": [
13 | "--extensionDevelopmentPath=${workspaceFolder}"
14 | ]
15 | }
16 | ]
17 | }
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "deno.enable": true,
3 | "deno.unstable": true
4 | }
5 |
--------------------------------------------------------------------------------
/.vscodeignore:
--------------------------------------------------------------------------------
1 | .vscode/**
2 | .vscode-test/**
3 | .gitignore
4 | vsc-extension-quickstart.md
5 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to the "modern-vue-snippets" extension will be documented in this file.
4 |
5 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
6 |
7 | ## [Unreleased]
8 |
9 | - Initial release
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2022 Matija Osrecki
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Vue Ecosystem Snippets
2 |
3 | > Snippets for the modern Vue ecosystem - including Nuxt 3, Pinia, VueUse, Vue Router & Vue Macros.
4 |
5 | 
6 | 
7 | 
8 |
9 | ## Features
10 | - Only the latest Vue syntax
11 | - Over **200** snippets
12 | - TypeScript-first
13 | - Nuxt 3, Pinia, VueUse, Vue Router & Vue Macros support
14 | - Strategically placed tabstops
15 | - Prefixes created with exact-match in mind
16 | - GitHub Copilot compliant
17 | - Auto-generated documentation
18 |
19 | ## Setup
20 | Not mandatory, but highly recommended.
21 |
22 | Look for it in user settings, or edit the settings.json directly:
23 | ```jsonc
24 | "editor.formatOnSave": true,
25 |
26 | // Tab complete snippets when their prefix match.
27 | "editor.tabCompletion": "onlySnippets"
28 | ```
29 |
30 | ## Snippet syntax
31 |
32 | ### Tabstops
33 | - `$1`, `$2`, `$3` specify cursor locations, in order in which tabstops will be visited
34 | - `$0` denotes the final cursor position
35 | - Multiple occurrences of the same tabstop are linked and updated in sync
36 |
37 | ### Placeholders
38 | - Tabstops with default values → `${1:name}`
39 |
40 | ### Choices
41 | - Tabstops with multiple values → `${1|one,two,three|}`.
42 | - Truncated in documentation, for easier viewing → `${1|one,...|}`.
43 |
44 | ## Snippets
45 |
46 | ### Vue SFC
47 | `.vue` files
48 |
49 |
50 |
51 | Prefix |
52 | Name |
53 | Body |
54 |
55 |
56 |
57 | vbase |
58 | Vue SFC |
59 |
60 |
61 | ```html
62 |
65 |
66 |
67 | $1
68 |
69 |
70 | ```
71 |
72 | |
73 |
74 |
75 |
76 | vbase:full |
77 | Vue SFC with style | postcss |
78 |
79 |
80 | ```html
81 |
84 |
85 |
86 | $1
87 |
88 |
89 |
92 |
93 | ```
94 |
95 | |
96 |
97 |
98 |
99 | vbase:full:css |
100 | Vue SFC with style | css |
101 |
102 |
103 | ```html
104 |
107 |
108 |
109 | $1
110 |
111 |
112 |
115 |
116 | ```
117 |
118 | |
119 |
120 |
121 |
122 | vbase:full:scss |
123 | Vue SFC with style | scss |
124 |
125 |
126 | ```html
127 |
130 |
131 |
132 | $1
133 |
134 |
135 |
138 |
139 | ```
140 |
141 | |
142 |
143 |
144 |
145 | vbase:full:less |
146 | Vue SFC with style | less |
147 |
148 |
149 | ```html
150 |
153 |
154 |
155 | $1
156 |
157 |
158 |
161 |
162 | ```
163 |
164 | |
165 |
166 |
167 |
168 | vscript |
169 | Vue script setup | ts |
170 |
171 |
172 | ```html
173 |
176 |
177 | ```
178 |
179 | |
180 |
181 |
182 |
183 | vscript:js |
184 | Vue script setup | js |
185 |
186 |
187 | ```html
188 |
191 |
192 | ```
193 |
194 | |
195 |
196 |
197 |
198 | vtemplate |
199 | Vue template |
200 |
201 |
202 | ```html
203 |
204 | $0
205 |
206 |
207 | ```
208 |
209 | |
210 |
211 |
212 |
213 | vstyle |
214 | Vue scoped style | postcss |
215 |
216 |
217 | ```html
218 |
221 |
222 | ```
223 |
224 | |
225 |
226 |
227 |
228 | vstyle:lang |
229 | Vue style with language option |
230 |
231 |
232 | ```html
233 |
236 |
237 | ```
238 |
239 | |
240 |
241 |
242 |
243 | vstyle:css |
244 | Vue scoped style | css |
245 |
246 |
247 | ```html
248 |
251 |
252 | ```
253 |
254 | |
255 |
256 |
257 |
258 | vstyle:scss |
259 | scoped style | scss |
260 |
261 |
262 | ```html
263 |
266 |
267 | ```
268 |
269 | |
270 |
271 |
272 |
273 | vstyle:less |
274 | scoped style | less |
275 |
276 |
277 | ```html
278 |
281 |
282 | ```
283 |
284 | |
285 |
286 |
287 |
288 | vstyle:module |
289 | Vue style with CSS modules |
290 |
291 |
292 | ```html
293 |
296 |
297 | ```
298 |
299 | |
300 |
301 |
302 |
303 | vstyle:src |
304 | Vue scoped style with src |
305 |
306 |
307 | ```html
308 |
311 |
312 | ```
313 |
314 | |
315 |
316 |
317 |
318 |
319 | ### Template
320 |
321 |
322 |
323 |
324 | Prefix |
325 | Name |
326 | Body |
327 |
328 |
329 |
330 | slot |
331 | slot |
332 |
333 |
334 | ```html
335 | $0
336 | ```
337 |
338 | |
339 |
340 |
341 |
342 | template / vtemplate |
343 | template |
344 |
345 |
346 | ```html
347 | $0
348 | ```
349 |
350 | |
351 |
352 |
353 |
354 | component / vcomponent |
355 | component |
356 |
357 |
358 | ```html
359 | $0
360 | ```
361 |
362 | |
363 |
364 |
365 |
366 | nslot |
367 | named slot |
368 |
369 |
370 | ```html
371 |
372 | $0
373 |
374 | ```
375 |
376 | |
377 |
378 |
379 |
380 | ntemplate |
381 | named template |
382 |
383 |
384 | ```html
385 |
386 | $0
387 |
388 | ```
389 |
390 | |
391 |
392 |
393 |
394 | vcomponent |
395 | Vue component |
396 |
397 |
398 | ```html
399 | $0
400 | ```
401 |
402 | |
403 |
404 |
405 |
406 | vKeepAlive |
407 | Vue KeepAlive |
408 |
409 |
410 | ```html
411 |
412 | $0
413 |
414 | ```
415 |
416 | |
417 |
418 |
419 |
420 | vTeleport |
421 | Vue teleport |
422 |
423 |
424 | ```html
425 |
426 | $0
427 |
428 | ```
429 |
430 | |
431 |
432 |
433 |
434 | vTransition |
435 | Vue Transition |
436 |
437 |
438 | ```html
439 |
440 | $0
441 |
442 | ```
443 |
444 | |
445 |
446 |
447 |
448 | vTransition:name / nTransition |
449 | Vue Transition with name |
450 |
451 |
452 | ```html
453 |
454 | $0
455 |
456 | ```
457 |
458 | |
459 |
460 |
461 |
462 | vTransition:type |
463 | Vue Transition with type |
464 |
465 |
466 | ```html
467 |
468 | $0
469 |
470 | ```
471 |
472 | |
473 |
474 |
475 |
476 | vTransition:appear |
477 | Vue Transition with appear |
478 |
479 |
480 | ```html
481 |
482 | $0
483 |
484 | ```
485 |
486 | |
487 |
488 |
489 |
490 | vTransitionGroup |
491 | Vue TransitionGroup |
492 |
493 |
494 | ```html
495 |
496 | $0
497 |
498 | ```
499 |
500 | |
501 |
502 |
503 |
504 | vSuspense |
505 | Vue Suspense |
506 |
507 |
508 | ```html
509 |
510 | $0
511 |
512 | ```
513 |
514 | |
515 |
516 |
517 |
518 | vSuspense:fallback |
519 | Vue Suspense with fallback |
520 |
521 |
522 | ```html
523 |
524 | $0
525 |
526 | $1
527 |
528 |
529 | ```
530 |
531 | |
532 |
533 |
534 |
535 | vtext |
536 | v-text |
537 |
538 |
539 | ```html
540 | v-text="$1"
541 | ```
542 |
543 | |
544 |
545 |
546 |
547 | vhtml |
548 | v-html |
549 |
550 |
551 | ```html
552 | v-html="$1"
553 | ```
554 |
555 | |
556 |
557 |
558 |
559 | vshow |
560 | v-show |
561 |
562 |
563 | ```html
564 | v-show="$1"
565 | ```
566 |
567 | |
568 |
569 |
570 |
571 | vif / if |
572 | v-if |
573 |
574 |
575 | ```html
576 | v-if="$1"
577 | ```
578 |
579 | |
580 |
581 |
582 |
583 | veif / elif |
584 | v-else-if |
585 |
586 |
587 | ```html
588 | v-else-if="$1"
589 | ```
590 |
591 | |
592 |
593 |
594 |
595 | velse / else |
596 | v-else |
597 |
598 |
599 | ```html
600 | v-else
601 | ```
602 |
603 | |
604 |
605 |
606 |
607 | vfor |
608 | v-for |
609 |
610 |
611 | ```html
612 | v-for="${2:item} in ${1:items}" :key="$2$3"
613 | ```
614 |
615 | |
616 |
617 |
618 |
619 | vfori |
620 | v-for (indexed) |
621 |
622 |
623 | ```html
624 | v-for="(${2:item}, ${3:i}) in ${1:items}" :key="${4:$3}"
625 | ```
626 |
627 | |
628 |
629 |
630 |
631 | vforr |
632 | v-for range |
633 |
634 |
635 | ```html
636 | v-for="${1:n} in ${2:5}" :key="$1"
637 | ```
638 |
639 | |
640 |
641 |
642 |
643 | vemit / emit |
644 | emit |
645 |
646 |
647 | ```html
648 | emit('$1'$2)
649 | ```
650 |
651 | |
652 |
653 |
654 |
655 | vemit:pass |
656 | Vue pass emit |
657 |
658 |
659 | ```html
660 | @${1|click,input,...|}="\$emit('${2:$1}', \$event)"
661 | ```
662 |
663 | |
664 |
665 |
666 |
667 | von |
668 | v-on |
669 |
670 |
671 | ```html
672 | v-on="${1:emits}"
673 | ```
674 |
675 | |
676 |
677 |
678 |
679 | von:event / voe |
680 | event handler |
681 |
682 |
683 | ```html
684 | @$1="$2"
685 | ```
686 |
687 | |
688 |
689 |
690 |
691 | von:click / voc |
692 | click handler |
693 |
694 |
695 | ```html
696 | @click="${1:onClick}"
697 | ```
698 |
699 | |
700 |
701 |
702 |
703 | von:input / voi |
704 | input handler |
705 |
706 |
707 | ```html
708 | @input="${1:onInput}"
709 | ```
710 |
711 | |
712 |
713 |
714 |
715 | von:update |
716 | update handler |
717 |
718 |
719 | ```html
720 | @update="${1:onUpdate}"
721 | ```
722 |
723 | |
724 |
725 |
726 |
727 | von:change |
728 | change handler |
729 |
730 |
731 | ```html
732 | @change="${1:onChange}"
733 | ```
734 |
735 | |
736 |
737 |
738 |
739 | von:blur |
740 | blur handler |
741 |
742 |
743 | ```html
744 | @blur="${1:onBlur}"
745 | ```
746 |
747 | |
748 |
749 |
750 |
751 | von:focus |
752 | focus handler |
753 |
754 |
755 | ```html
756 | @focus="${1:onFocus}"
757 | ```
758 |
759 | |
760 |
761 |
762 |
763 | von:submit |
764 | submit handler |
765 |
766 |
767 | ```html
768 | @submit${1:.prevent}="${2:onSubmit}"
769 | ```
770 |
771 | |
772 |
773 |
774 |
775 | vbind |
776 | v-bind |
777 |
778 |
779 | ```html
780 | v-bind="$1"
781 | ```
782 |
783 | |
784 |
785 |
786 |
787 | vbind:attrs |
788 | v-bind attrs |
789 |
790 |
791 | ```html
792 | v-bind="\$attrs"
793 | ```
794 |
795 | |
796 |
797 |
798 |
799 | vbind:props |
800 | v-bind props |
801 |
802 |
803 | ```html
804 | v-bind="\$props"
805 | ```
806 |
807 | |
808 |
809 |
810 |
811 | vbind:full |
812 | v-bind props and attrs |
813 |
814 |
815 | ```html
816 | v-bind="[\$props, \$attrs]"
817 | ```
818 |
819 | |
820 |
821 |
822 |
823 | vmodel |
824 | v-model |
825 |
826 |
827 | ```html
828 | v-model="$1"
829 | ```
830 |
831 | |
832 |
833 |
834 |
835 | vmodel:number |
836 | v-model.number |
837 |
838 |
839 | ```html
840 | v-model.number="$1"
841 | ```
842 |
843 | |
844 |
845 |
846 |
847 | vmodel:trim |
848 | v-model.trim |
849 |
850 |
851 | ```html
852 | v-model.trim="$1"
853 | ```
854 |
855 | |
856 |
857 |
858 |
859 | vmodel:custom |
860 | custom v-model |
861 |
862 |
863 | ```html
864 | v-model:${1:custom}="$2"
865 | ```
866 |
867 | |
868 |
869 |
870 |
871 | vslot |
872 | scoped slot |
873 |
874 |
875 | ```html
876 | v-slot="{$1}"
877 | ```
878 |
879 | |
880 |
881 |
882 |
883 | vpre |
884 | v-pre |
885 |
886 |
887 | ```html
888 | v-pre="$1"
889 | ```
890 |
891 | |
892 |
893 |
894 |
895 | vonce |
896 | v-once |
897 |
898 |
899 | ```html
900 | v-once
901 | ```
902 |
903 | |
904 |
905 |
906 |
907 | vmemo |
908 | v-memo |
909 |
910 |
911 | ```html
912 | v-memo="[$1]"
913 | ```
914 |
915 | |
916 |
917 |
918 |
919 | vcloak |
920 | v-cloak |
921 |
922 |
923 | ```html
924 | v-cloak
925 | ```
926 |
927 | |
928 |
929 |
930 |
931 | vkey |
932 | Vue key |
933 |
934 |
935 | ```html
936 | :key="$1"
937 | ```
938 |
939 | |
940 |
941 |
942 |
943 | vref |
944 | Vue ref |
945 |
946 |
947 | ```html
948 | ref="$1"
949 | ```
950 |
951 | |
952 |
953 |
954 |
955 | vname |
956 | name property |
957 |
958 |
959 | ```html
960 | ${1|name,:name|}="$2"
961 | ```
962 |
963 | |
964 |
965 |
966 |
967 | vis |
968 | is property |
969 |
970 |
971 | ```html
972 | ${1|is,:is|}="$2"
973 | ```
974 |
975 | |
976 |
977 |
978 |
979 | vb |
980 | bind attribute |
981 |
982 |
983 | ```html
984 | :${1:prop}="${2:$1}"
985 | ```
986 |
987 | |
988 |
989 |
990 |
991 | va |
992 | attribute |
993 |
994 |
995 | ```html
996 | ${1:prop}="$2"
997 | ```
998 |
999 | |
1000 |
1001 |
1002 |
1003 | vclass / vc |
1004 | Vue classes |
1005 |
1006 |
1007 | ```html
1008 | :class="$1"
1009 | ```
1010 |
1011 | |
1012 |
1013 |
1014 |
1015 | vclass:list / vca |
1016 | Vue classes list |
1017 |
1018 |
1019 | ```html
1020 | :class="[$1]"
1021 | ```
1022 |
1023 | |
1024 |
1025 |
1026 |
1027 | vclass:cond / vcc |
1028 | Vue conditional classes |
1029 |
1030 |
1031 | ```html
1032 | :class="{ $1: $2 }"
1033 | ```
1034 |
1035 | |
1036 |
1037 |
1038 |
1039 | vstyle |
1040 | Vue inline style |
1041 |
1042 |
1043 | ```html
1044 | :style="{ $1: $2 }"
1045 | ```
1046 |
1047 | |
1048 |
1049 |
1050 |
1051 | vstyle:list |
1052 | Vue inline style list |
1053 |
1054 |
1055 | ```html
1056 | :style="[$1]"
1057 | ```
1058 |
1059 | |
1060 |
1061 |
1062 |
1063 | vv |
1064 | Vue |
1065 |
1066 |
1067 | ```html
1068 | {{ $1 }}
1069 | ```
1070 |
1071 | |
1072 |
1073 |
1074 |
1075 | vvt |
1076 | Vue i18n translation |
1077 |
1078 |
1079 | ```html
1080 | {{ t('$1') }}
1081 | ```
1082 |
1083 | |
1084 |
1085 |
1086 |
1087 | vif:slot |
1088 | v-if slot defined |
1089 |
1090 |
1091 | ```html
1092 | v-if="\$slots.${1:default}"
1093 | ```
1094 |
1095 | |
1096 |
1097 |
1098 |
1099 | vif:slot-prop |
1100 | v-if slot or prop defined |
1101 |
1102 |
1103 | ```html
1104 | v-if="\$slots.${1:label} || ${2:$1}"
1105 | ```
1106 |
1107 | |
1108 |
1109 |
1110 |
1111 | vform |
1112 | form submit.prevent |
1113 |
1114 |
1115 | ```html
1116 |
1119 | ```
1120 |
1121 | |
1122 |
1123 |
1124 |
1125 | vfor:template |
1126 | v-for in template |
1127 |
1128 |
1129 | ```html
1130 | <${1|template,div,...|} v-for="${3:item} in ${2:items}" :key="$3$4">
1131 | $0
1132 | $1>
1133 | ```
1134 |
1135 | |
1136 |
1137 |
1138 |
1139 | vfori:template |
1140 | v-for (indexed) in template |
1141 |
1142 |
1143 | ```html
1144 | <${1|template,div,...|} v-for="(${3:item}, ${4:i}) in ${2:items}" :key="${5:$4}">
1145 | $0
1146 | $1>
1147 | ```
1148 |
1149 | |
1150 |
1151 |
1152 |
1153 | vif:template |
1154 | v-if in template |
1155 |
1156 |
1157 | ```html
1158 | <${1|template,div,...|} v-if="$2">
1159 | $0
1160 | $1>
1161 | ```
1162 |
1163 | |
1164 |
1165 |
1166 |
1167 | vtif |
1168 | template with v-if |
1169 |
1170 |
1171 | ```html
1172 |
1173 | $0
1174 |
1175 | ```
1176 |
1177 | |
1178 |
1179 |
1180 |
1181 | vdif |
1182 | div with v-if |
1183 |
1184 |
1185 | ```html
1186 |
1187 | $0
1188 |
1189 | ```
1190 |
1191 | |
1192 |
1193 |
1194 |
1195 |
1196 | ### Style
1197 |
1198 |
1259 |
1260 |
1261 | Prefix |
1262 | Name |
1263 | Body |
1264 |
1265 |
1266 |
1267 | vref / vr |
1268 | Vue ref |
1269 |
1270 |
1271 | ```javascript
1272 | const ${1:name} = ref($2)
1273 | ```
1274 |
1275 | |
1276 |
1277 |
1278 |
1279 | vref:ts / vrt |
1280 | Vue ref (typed) |
1281 |
1282 |
1283 | ```javascript
1284 | const ${1:name} = ref<$2>($3)
1285 | ```
1286 |
1287 | |
1288 |
1289 |
1290 |
1291 | vcomputed / vc |
1292 | Vue computed |
1293 |
1294 |
1295 | ```javascript
1296 | const ${1:name} = computed(() => $2)
1297 | ```
1298 |
1299 | |
1300 |
1301 |
1302 |
1303 | vcomputed:ts / vct |
1304 | Vue computed (typed) |
1305 |
1306 |
1307 | ```javascript
1308 | const ${1:name} = computed<$2>(() => $3)
1309 | ```
1310 |
1311 | |
1312 |
1313 |
1314 |
1315 | vcomputed:gs / vcgs |
1316 | Vue computed (get/set) |
1317 |
1318 |
1319 | ```javascript
1320 | const ${1:name} = computed({
1321 | get: () => ${2},
1322 | set: (${3:value}: ${4:string}) => {
1323 | ${5}
1324 | },
1325 | })
1326 | ```
1327 |
1328 | |
1329 |
1330 |
1331 |
1332 | vreactive / vra |
1333 | Vue reactive |
1334 |
1335 |
1336 | ```javascript
1337 | const ${1:name} = reactive({$2})
1338 | ```
1339 |
1340 | |
1341 |
1342 |
1343 |
1344 | vreactive:ts |
1345 | Vue reactive (typed) |
1346 |
1347 |
1348 | ```javascript
1349 | const ${1:name}: ${2:type} = reactive({$3})
1350 | ```
1351 |
1352 | |
1353 |
1354 |
1355 |
1356 | vshallowRef |
1357 | Vue shallowRef |
1358 |
1359 |
1360 | ```javascript
1361 | const ${1:name} = shallowRef($2)
1362 | ```
1363 |
1364 | |
1365 |
1366 |
1367 |
1368 | vtoRef |
1369 | Vue toRef |
1370 |
1371 |
1372 | ```javascript
1373 | toRef(${1:props}, '$2')
1374 | ```
1375 |
1376 | |
1377 |
1378 |
1379 |
1380 | vtoRefs |
1381 | Vue toRefs |
1382 |
1383 |
1384 | ```javascript
1385 | toRefs(${1:props})
1386 | ```
1387 |
1388 | |
1389 |
1390 |
1391 |
1392 | vunref |
1393 | Vue unref |
1394 |
1395 |
1396 | ```javascript
1397 | unref($1)
1398 | ```
1399 |
1400 | |
1401 |
1402 |
1403 |
1404 | vreadonly |
1405 | Vue readonly |
1406 |
1407 |
1408 | ```javascript
1409 | readonly(${1:object})
1410 | ```
1411 |
1412 | |
1413 |
1414 |
1415 |
1416 | vref:elem |
1417 | Vue element ref |
1418 |
1419 |
1420 | ```javascript
1421 | const ${1:elem} = ref<${2|HTMLInputElement,HTMLInputElement,...|} | null>(null)
1422 | ```
1423 |
1424 | |
1425 |
1426 |
1427 |
1428 | vwatchEffect |
1429 | Vue watchEffect |
1430 |
1431 |
1432 | ```javascript
1433 | watchEffect(() => {
1434 | $0
1435 | })
1436 | ```
1437 |
1438 | |
1439 |
1440 |
1441 |
1442 | vwatch |
1443 | Vue watch source |
1444 |
1445 |
1446 | ```javascript
1447 | watch(${1:source}, (${2:val}) => {
1448 | $0
1449 | })
1450 | ```
1451 |
1452 | |
1453 |
1454 |
1455 |
1456 | vwatch:inline |
1457 | Vue watch inline |
1458 |
1459 |
1460 | ```javascript
1461 | watch(${1:source}, ${2:fn})
1462 | ```
1463 |
1464 | |
1465 |
1466 |
1467 |
1468 | vwatch:getter |
1469 | Vue watch getter |
1470 |
1471 |
1472 | ```javascript
1473 | watch(() => ${1:source}, (${2:val}) => {
1474 | $0
1475 | })
1476 | ```
1477 |
1478 | |
1479 |
1480 |
1481 |
1482 | vwatch:multiple |
1483 | Vue watch multiple |
1484 |
1485 |
1486 | ```javascript
1487 | watch([${1:source1}, ${2:source2}], ([new${1/(.*)/${1:/capitalize}/}, new${2/(.*)/${1:/capitalize}/}]) => {
1488 | $0
1489 | })
1490 | ```
1491 |
1492 | |
1493 |
1494 |
1495 |
1496 | vwatch:immediate |
1497 | Vue watch immediate |
1498 |
1499 |
1500 | ```javascript
1501 | watch(${1:source}, (${2:val}) => {
1502 | $0
1503 | }, { immediate: true })
1504 | ```
1505 |
1506 | |
1507 |
1508 |
1509 |
1510 | vwatch:deep |
1511 | Vue watch deep |
1512 |
1513 |
1514 | ```javascript
1515 | watch(${1:source}, (${2:val}) => {
1516 | $0
1517 | }, { deep: true })
1518 | ```
1519 |
1520 | |
1521 |
1522 |
1523 |
1524 | vwatch:log / vwl |
1525 | Vue watch source | log |
1526 |
1527 |
1528 | ```javascript
1529 | watch(${1:source}, (${2:val}) => {
1530 | console.log('$1:', $2)
1531 | })
1532 | ```
1533 |
1534 | |
1535 |
1536 |
1537 |
1538 | vprops |
1539 | Vue defineProps |
1540 |
1541 |
1542 | ```javascript
1543 | ${1:const props = }defineProps<${2:Props}>()
1544 | ```
1545 |
1546 | |
1547 |
1548 |
1549 |
1550 | vprops:defaults |
1551 | Vue defineProps with defaults |
1552 |
1553 |
1554 | ```javascript
1555 | ${1:const props = }withDefaults(defineProps<${2:Props}>(), {
1556 | $0
1557 | })
1558 | ```
1559 |
1560 | |
1561 |
1562 |
1563 |
1564 | vprops:js |
1565 | Vue defineProps without TS |
1566 |
1567 |
1568 | ```javascript
1569 | ${1:const props = }defineProps({
1570 | $2
1571 | })
1572 | ```
1573 |
1574 | |
1575 |
1576 |
1577 |
1578 | vemits |
1579 | Vue defineEmits |
1580 |
1581 |
1582 | ```javascript
1583 | ${1:const emit = }defineEmits<{
1584 | ${2:click}: [${3:payload}: ${4:string}],$5
1585 | }>()
1586 | ```
1587 |
1588 | |
1589 |
1590 |
1591 |
1592 | vemits:alt |
1593 | Vue defineEmits without TS |
1594 |
1595 |
1596 | ```javascript
1597 | ${1:const emit = }defineEmits(['$2'])
1598 | ```
1599 |
1600 | |
1601 |
1602 |
1603 |
1604 | vemits:old |
1605 | Vue defineEmits (old syntax) |
1606 |
1607 |
1608 | ```javascript
1609 | ${1:const emit = }defineEmits<{
1610 | (e: '${2:click}', ${3:payload}: ${4:string}): void,$5
1611 | }>()
1612 | ```
1613 |
1614 | |
1615 |
1616 |
1617 |
1618 | vmodel |
1619 | Vue defineModel |
1620 |
1621 |
1622 | ```javascript
1623 | const ${1:modelValue} = defineModel<${2:string}>($3)
1624 | ```
1625 |
1626 | |
1627 |
1628 |
1629 |
1630 | vemit |
1631 | Vue emit event |
1632 |
1633 |
1634 | ```javascript
1635 | emit('$1'$2)
1636 | ```
1637 |
1638 | |
1639 |
1640 |
1641 |
1642 | vexpose |
1643 | Vue defineExpose |
1644 |
1645 |
1646 | ```javascript
1647 | defineExpose({
1648 | $1
1649 | })
1650 | ```
1651 |
1652 | |
1653 |
1654 |
1655 |
1656 | v:onMounted |
1657 | Vue onMounted |
1658 |
1659 |
1660 | ```javascript
1661 | onMounted(() => {
1662 | $0
1663 | })
1664 | ```
1665 |
1666 | |
1667 |
1668 |
1669 |
1670 | v:onBeforeMount |
1671 | Vue onBeforeMount |
1672 |
1673 |
1674 | ```javascript
1675 | onBeforeMount(() => {
1676 | $0
1677 | })
1678 | ```
1679 |
1680 | |
1681 |
1682 |
1683 |
1684 | v:onUnmounted |
1685 | Vue onUnmounted |
1686 |
1687 |
1688 | ```javascript
1689 | onUnmounted(() => {
1690 | $0
1691 | })
1692 | ```
1693 |
1694 | |
1695 |
1696 |
1697 |
1698 | v:onBeforeUnmount |
1699 | Vue onBeforeUnmount |
1700 |
1701 |
1702 | ```javascript
1703 | onBeforeUnmount(() => {
1704 | $0
1705 | })
1706 | ```
1707 |
1708 | |
1709 |
1710 |
1711 |
1712 | v:onUpdated |
1713 | Vue onUpdated |
1714 |
1715 |
1716 | ```javascript
1717 | onUpdated(() => {
1718 | $0
1719 | })
1720 | ```
1721 |
1722 | |
1723 |
1724 |
1725 |
1726 | v:onBeforeUpdate |
1727 | Vue onBeforeUpdate |
1728 |
1729 |
1730 | ```javascript
1731 | onBeforeUpdate(() => {
1732 | $0
1733 | })
1734 | ```
1735 |
1736 | |
1737 |
1738 |
1739 |
1740 | v:onErrorCaptured |
1741 | Vue onErrorCaptured |
1742 |
1743 |
1744 | ```javascript
1745 | onErrorCaptured(() => {
1746 | $0
1747 | })
1748 | ```
1749 |
1750 | |
1751 |
1752 |
1753 |
1754 | v:onActivated |
1755 | Vue onActivated |
1756 |
1757 |
1758 | ```javascript
1759 | onActivated(() => {
1760 | $0
1761 | })
1762 | ```
1763 |
1764 | |
1765 |
1766 |
1767 |
1768 | v:onDeactivated |
1769 | Vue onDeactivated |
1770 |
1771 |
1772 | ```javascript
1773 | onDeactivated(() => {
1774 | $0
1775 | })
1776 | ```
1777 |
1778 | |
1779 |
1780 |
1781 |
1782 | vprovide |
1783 | Vue provide |
1784 |
1785 |
1786 | ```javascript
1787 | provide(${1:key}, ${2:value})
1788 | ```
1789 |
1790 | |
1791 |
1792 |
1793 |
1794 | vprovide:ts |
1795 | Vue provide (typed) |
1796 |
1797 |
1798 | ```javascript
1799 | provide<${1:string}>(${2:key}, ${3:value})
1800 | ```
1801 |
1802 | |
1803 |
1804 |
1805 |
1806 | vinject |
1807 | Vue inject |
1808 |
1809 |
1810 | ```javascript
1811 | const ${1:value} = inject(${2:key})
1812 | ```
1813 |
1814 | |
1815 |
1816 |
1817 |
1818 | vinject:ts |
1819 | Vue inject (typed) |
1820 |
1821 |
1822 | ```javascript
1823 | const ${1:value} = inject<${2:string}>(${3:key})
1824 | ```
1825 |
1826 | |
1827 |
1828 |
1829 |
1830 | vinject:default |
1831 | Vue inject with default |
1832 |
1833 |
1834 | ```javascript
1835 | const ${1:value} = inject(${2:key}, ${3:defaultValue})
1836 | ```
1837 |
1838 | |
1839 |
1840 |
1841 |
1842 | vinjectkey |
1843 | Vue injection key |
1844 |
1845 |
1846 | ```javascript
1847 | const ${1:key} = Symbol('$2') as InjectionKey<${3:string}>
1848 | ```
1849 |
1850 | |
1851 |
1852 |
1853 |
1854 | vslots |
1855 | Vue useSlots |
1856 |
1857 |
1858 | ```javascript
1859 | const slots = useSlots()
1860 | ```
1861 |
1862 | |
1863 |
1864 |
1865 |
1866 | vattrs |
1867 | Vue useAttrs |
1868 |
1869 |
1870 | ```javascript
1871 | const attrs = useAttrs()
1872 | ```
1873 |
1874 | |
1875 |
1876 |
1877 |
1878 | vimport / vim |
1879 | Import from vue |
1880 |
1881 |
1882 | ```javascript
1883 | import { $1 } from 'vue'
1884 | ```
1885 |
1886 | |
1887 |
1888 |
1889 |
1890 | ### Code snippets
1891 | Useful vue snippets and helpers
1892 |
2269 |
2270 |
2271 | Prefix |
2272 | Name |
2273 | Body |
2274 |
2275 |
2276 |
2277 | nfetch |
2278 | Nuxt useFetch |
2279 |
2280 |
2281 | ```javascript
2282 | const { data: ${1:data} } = await useFetch('$2'$3)
2283 | ```
2284 |
2285 | |
2286 |
2287 |
2288 |
2289 | nfetch:cb |
2290 | Nuxt useFetch with callback |
2291 |
2292 |
2293 | ```javascript
2294 | const { data: ${1:data} } = await useFetch(() => '$2'$3)
2295 | ```
2296 |
2297 | |
2298 |
2299 |
2300 |
2301 | nfetch:lazy |
2302 | Nuxt useLazyFetch |
2303 |
2304 |
2305 | ```javascript
2306 | const { pending, data: ${1:data} } = useLazyFetch('$2'$3)
2307 | ```
2308 |
2309 | |
2310 |
2311 |
2312 |
2313 | nfetch:lazy:cb |
2314 | Nuxt useLazyFetch callback |
2315 |
2316 |
2317 | ```javascript
2318 | const { pending, data: ${1:data} } = useLazyFetch(() => '$2'$3)
2319 | ```
2320 |
2321 | |
2322 |
2323 |
2324 |
2325 | nfetch:post |
2326 | Nuxt useFetch POST |
2327 |
2328 |
2329 | ```javascript
2330 | const { data: ${1:data} } = await useFetch('$2', {
2331 | method: 'POST',
2332 | body: ${3:body},$4
2333 | })
2334 | ```
2335 |
2336 | |
2337 |
2338 |
2339 |
2340 | nasyncdata |
2341 | Nuxt useAsyncData |
2342 |
2343 |
2344 | ```javascript
2345 | const { data: ${1:data} } = await useAsyncData('${2:key}', () => $fetch('$3')$4)
2346 | ```
2347 |
2348 | |
2349 |
2350 |
2351 |
2352 | nasyncdata:lazy |
2353 | Nuxt useLazyAsyncData |
2354 |
2355 |
2356 | ```javascript
2357 | const { pending, data: ${1:data} } = useLazyAsyncData('${2:key}', () => $fetch('$3')$4)
2358 | ```
2359 |
2360 | |
2361 |
2362 |
2363 |
2364 | napp |
2365 | Nuxt useNuxtApp |
2366 |
2367 |
2368 | ```javascript
2369 | const app = useNuxtApp()
2370 | ```
2371 |
2372 | |
2373 |
2374 |
2375 |
2376 | nappConfig |
2377 | Nuxt useAppConfig |
2378 |
2379 |
2380 | ```javascript
2381 | const appConfig = useAppConfig()
2382 | ```
2383 |
2384 | |
2385 |
2386 |
2387 |
2388 | nruntimeConfig |
2389 | Nuxt useRuntimeConfig |
2390 |
2391 |
2392 | ```javascript
2393 | const config = useRuntimeConfig()
2394 | ```
2395 |
2396 | |
2397 |
2398 |
2399 |
2400 | ncookie |
2401 | Nuxt useCookie |
2402 |
2403 |
2404 | ```javascript
2405 | const ${1:cookie} = useCookie('${2:$1}'$3)
2406 | ```
2407 |
2408 | |
2409 |
2410 |
2411 |
2412 | ncookie:opts |
2413 | Nuxt useCookie with options |
2414 |
2415 |
2416 | ```javascript
2417 | const ${1:cookie} = useCookie('${2:$1}', { $3 })
2418 | ```
2419 |
2420 | |
2421 |
2422 |
2423 |
2424 | ndata |
2425 | Nuxt useNuxtData |
2426 |
2427 |
2428 | ```javascript
2429 | const { data: ${2:$1} } = useNuxtData('${1:key}')
2430 | ```
2431 |
2432 | |
2433 |
2434 |
2435 |
2436 | nerror |
2437 | Nuxt useError |
2438 |
2439 |
2440 | ```javascript
2441 | const ${1:error} = useError()
2442 | ```
2443 |
2444 | |
2445 |
2446 |
2447 |
2448 | nstate |
2449 | Nuxt useState |
2450 |
2451 |
2452 | ```javascript
2453 | const ${1:state} = useState('${2:$1}'$3)
2454 | ```
2455 |
2456 | |
2457 |
2458 |
2459 |
2460 | nstate:init |
2461 | Nuxt useState (init) |
2462 |
2463 |
2464 | ```javascript
2465 | const ${1:state} = useState('${2:$1}', () => $3)
2466 | ```
2467 |
2468 | |
2469 |
2470 |
2471 |
2472 | nhead |
2473 | Nuxt useHead |
2474 |
2475 |
2476 | ```javascript
2477 | useHead({
2478 | $1
2479 | })
2480 | ```
2481 |
2482 | |
2483 |
2484 |
2485 |
2486 | nhead:title |
2487 | Nuxt useHead title |
2488 |
2489 |
2490 | ```javascript
2491 | useHead({
2492 | title: $1,$0
2493 | })
2494 | ```
2495 |
2496 | |
2497 |
2498 |
2499 |
2500 | npageMeta |
2501 | Nuxt definePageMeta |
2502 |
2503 |
2504 | ```javascript
2505 | definePageMeta({
2506 | $1
2507 | })
2508 | ```
2509 |
2510 | |
2511 |
2512 |
2513 |
2514 | npageMeta:title |
2515 | Nuxt definePageMeta title |
2516 |
2517 |
2518 | ```javascript
2519 | definePageMeta({
2520 | title: '$1',$0
2521 | })
2522 | ```
2523 |
2524 | |
2525 |
2526 |
2527 |
2528 | npageMeta:layout |
2529 | Nuxt definePageMeta layout |
2530 |
2531 |
2532 | ```javascript
2533 | definePageMeta({
2534 | layout: '$1',$0
2535 | })
2536 | ```
2537 |
2538 | |
2539 |
2540 |
2541 |
2542 | npageMeta:middleware |
2543 | Nuxt definePageMeta middleware |
2544 |
2545 |
2546 | ```javascript
2547 | definePageMeta({
2548 | middleware: ['$1'$2],$0
2549 | })
2550 | ```
2551 |
2552 | |
2553 |
2554 |
2555 |
2556 | nto |
2557 | Nuxt navigateTo |
2558 |
2559 |
2560 | ```javascript
2561 | navigateTo('$1'$2)
2562 | ```
2563 |
2564 | |
2565 |
2566 |
2567 |
2568 | nto:obj |
2569 | Nuxt navigateTo object |
2570 |
2571 |
2572 | ```javascript
2573 | navigateTo({ $1 }$2)
2574 | ```
2575 |
2576 | |
2577 |
2578 |
2579 |
2580 | nto:replace |
2581 | Nuxt navigateTo replace |
2582 |
2583 |
2584 | ```javascript
2585 | navigateTo('$1', { replace: true })
2586 | ```
2587 |
2588 | |
2589 |
2590 |
2591 |
2592 | nto:external |
2593 | Nuxt navigateTo external |
2594 |
2595 |
2596 | ```javascript
2597 | navigateTo('$1', { external: true })
2598 | ```
2599 |
2600 | |
2601 |
2602 |
2603 |
2604 | nto:redirect |
2605 | Nuxt navigateTo redirect |
2606 |
2607 |
2608 | ```javascript
2609 | navigateTo('$1', { redirectCode: ${2|301,302,...|} })
2610 | ```
2611 |
2612 | |
2613 |
2614 |
2615 |
2616 | nto:name |
2617 | Nuxt navigateTo name |
2618 |
2619 |
2620 | ```javascript
2621 | navigateTo({
2622 | name: '$1',$0
2623 | })
2624 | ```
2625 |
2626 | |
2627 |
2628 |
2629 |
2630 | nto:path |
2631 | Nuxt navigateTo path |
2632 |
2633 |
2634 | ```javascript
2635 | navigateTo({
2636 | path: '$1',$0
2637 | })
2638 | ```
2639 |
2640 | |
2641 |
2642 |
2643 |
2644 | nplugin |
2645 | Nuxt plugin |
2646 |
2647 |
2648 | ```javascript
2649 | export default defineNuxtPlugin((nuxtApp) => {
2650 | $1
2651 | })
2652 | ```
2653 |
2654 | |
2655 |
2656 |
2657 |
2658 | nplugin:vue |
2659 | Nuxt plugin use vue package |
2660 |
2661 |
2662 | ```javascript
2663 | export default defineNuxtPlugin((nuxtApp) => {
2664 | nuxtApp.vueApp.use($1)
2665 | })
2666 | ```
2667 |
2668 | |
2669 |
2670 |
2671 |
2672 | nmiddleware:route |
2673 | Nuxt route middleware |
2674 |
2675 |
2676 | ```javascript
2677 | export default defineNuxtRouteMiddleware((to, from) => {
2678 | $1
2679 | })
2680 | ```
2681 |
2682 | |
2683 |
2684 |
2685 |
2686 | nmiddleware:server |
2687 | Nuxt server middleware |
2688 |
2689 |
2690 | ```javascript
2691 | export default defineEventHandler((event) => {
2692 | $1
2693 | })
2694 | ```
2695 |
2696 | |
2697 |
2698 |
2699 |
2700 | napi |
2701 | Nuxt api route |
2702 |
2703 |
2704 | ```javascript
2705 | export default defineEventHandler(${1:async }(event) => {
2706 | $2
2707 |
2708 | return {
2709 | $3
2710 | }
2711 | })
2712 | ```
2713 |
2714 | |
2715 |
2716 |
2717 |
2718 | nplugin:server |
2719 | Nuxt server plugin |
2720 |
2721 |
2722 | ```javascript
2723 | export default defineNitroPlugin((nitroApp) => {
2724 | $1
2725 | })
2726 | ```
2727 |
2728 | |
2729 |
2730 |
2731 |
2732 | nreadBody |
2733 | Nuxt readBody |
2734 |
2735 |
2736 | ```javascript
2737 | const ${1:body} = await readBody(event)
2738 | ```
2739 |
2740 | |
2741 |
2742 |
2743 |
2744 | ngetQuery |
2745 | Nuxt getQuery |
2746 |
2747 |
2748 | ```javascript
2749 | const { $1 } = getQuery(event)
2750 | ```
2751 |
2752 | |
2753 |
2754 |
2755 |
2756 | ngetCookie |
2757 | Nuxt getCookie |
2758 |
2759 |
2760 | ```javascript
2761 | getCookie(event, '${1:cookie}')
2762 | ```
2763 |
2764 | |
2765 |
2766 |
2767 |
2768 | nsetCookie |
2769 | Nuxt setCookie |
2770 |
2771 |
2772 | ```javascript
2773 | setCookie(event, '${1:cookie}', ${2:value})
2774 | ```
2775 |
2776 | |
2777 |
2778 |
2779 |
2780 |
2781 | ### Nuxt (template)
2782 |
2783 |
2784 |
2785 |
2786 | Prefix |
2787 | Name |
2788 | Body |
2789 |
2790 |
2791 |
2792 | nlink |
2793 | NuxtLink |
2794 |
2795 |
2796 | ```html
2797 | $3
2798 | ```
2799 |
2800 | |
2801 |
2802 |
2803 |
2804 | nlink:blank |
2805 | NuxtLink with target _blank |
2806 |
2807 |
2808 | ```html
2809 | $4
2810 | ```
2811 |
2812 | |
2813 |
2814 |
2815 |
2816 | nlink:external |
2817 | NuxtLink with target external |
2818 |
2819 |
2820 | ```html
2821 | $5
2822 | ```
2823 |
2824 | |
2825 |
2826 |
2827 |
2828 | nlink:param |
2829 | NuxtLink with param |
2830 |
2831 |
2832 | ```html
2833 | $5
2834 | ```
2835 |
2836 | |
2837 |
2838 |
2839 |
2840 | nlink:obj |
2841 | NuxtLink with object |
2842 |
2843 |
2844 | ```html
2845 | $3
2846 | ```
2847 |
2848 | |
2849 |
2850 |
2851 |
2852 | nlink:name |
2853 | NuxtLink with name |
2854 |
2855 |
2856 | ```html
2857 | $4
2858 | ```
2859 |
2860 | |
2861 |
2862 |
2863 |
2864 | nlink:path |
2865 | NuxtLink with path |
2866 |
2867 |
2868 | ```html
2869 | $4
2870 | ```
2871 |
2872 | |
2873 |
2874 |
2875 |
2876 | nloading |
2877 | NuxtLoadingIndicator |
2878 |
2879 |
2880 | ```html
2881 |
2882 | ```
2883 |
2884 | |
2885 |
2886 |
2887 |
2888 | nlayout |
2889 | NuxtLayout |
2890 |
2891 |
2892 | ```html
2893 | $2
2894 | ```
2895 |
2896 | |
2897 |
2898 |
2899 |
2900 | nlayout:name |
2901 | NuxtLayout with name |
2902 |
2903 |
2904 | ```html
2905 | $4
2906 | ```
2907 |
2908 | |
2909 |
2910 |
2911 |
2912 | npage |
2913 | NuxtPage |
2914 |
2915 |
2916 | ```html
2917 |
2918 | ```
2919 |
2920 | |
2921 |
2922 |
2923 |
2924 | npage:static |
2925 | NuxtPage with static key |
2926 |
2927 |
2928 | ```html
2929 |
2930 | ```
2931 |
2932 | |
2933 |
2934 |
2935 |
2936 | nclient |
2937 | ClientOnly |
2938 |
2939 |
2940 | ```html
2941 | $2
2942 | ```
2943 |
2944 | |
2945 |
2946 |
2947 |
2948 | nclient:fallbacks |
2949 | ClientOnly with fallback props |
2950 |
2951 |
2952 | ```html
2953 | $3
2954 | ```
2955 |
2956 | |
2957 |
2958 |
2959 |
2960 | nclient:fallback |
2961 | ClientOnly with fallback template |
2962 |
2963 |
2964 | ```html
2965 |
2966 |
2967 | $0
2968 |
2969 |
2970 | ```
2971 |
2972 | |
2973 |
2974 |
2975 |
2976 | nTeleport |
2977 | Nuxt Teleport |
2978 |
2979 |
2980 | ```html
2981 |
2982 | $0
2983 |
2984 | ```
2985 |
2986 | |
2987 |
2988 |
2989 |
2990 |
2991 | ### VueUse (script)
2992 |
2993 |
2994 |
2995 |
2996 | Prefix |
2997 | Name |
2998 | Body |
2999 |
3000 |
3001 |
3002 | vRefAutoReset |
3003 | VueUse refAutoReset |
3004 |
3005 |
3006 | ```javascript
3007 | const ${1:name} = refAutoReset('$2', ${3:1000})
3008 | ```
3009 |
3010 | |
3011 |
3012 |
3013 |
3014 | vwatchArray |
3015 | VueUse watchArray |
3016 |
3017 |
3018 | ```javascript
3019 | watchArray(${1:list}, (new${1/(.*)/${1:/capitalize}/}, old${1/(.*)/${1:/capitalize}/}, ${4:added}, ${5:removed}) => {
3020 | $0
3021 | })
3022 | ```
3023 |
3024 | |
3025 |
3026 |
3027 |
3028 | vwatchAtMost |
3029 | VueUse watchAtMost |
3030 |
3031 |
3032 | ```javascript
3033 | watchAtMost(${1:source}, (${2:val}) => {
3034 | $0
3035 | }, { max: ${3:3} })
3036 | ```
3037 |
3038 | |
3039 |
3040 |
3041 |
3042 | vwatchDebounced |
3043 | VueUse watchDebounced |
3044 |
3045 |
3046 | ```javascript
3047 | watchDebounced(${1:source}, (${2:val}) => {
3048 | $0
3049 | }, { debounce: ${3:500}, maxWait: ${4:1000} })
3050 | ```
3051 |
3052 | |
3053 |
3054 |
3055 |
3056 | vwatchIgnorable |
3057 | VueUse watchIgnorable |
3058 |
3059 |
3060 | ```javascript
3061 | const { stop:$3, ignoreUpdates:$4 } = = watchIgnorable(${1:source}, (${2:val}) => {
3062 | $0
3063 | })
3064 | ```
3065 |
3066 | |
3067 |
3068 |
3069 |
3070 | vwatchOnce |
3071 | VueUse watchOnce |
3072 |
3073 |
3074 | ```javascript
3075 | watchOnce(${1:source}, (${2:val}) => {
3076 | $0
3077 | })
3078 | ```
3079 |
3080 | |
3081 |
3082 |
3083 |
3084 | vwatchImmediate |
3085 | VueUse watchImmediate |
3086 |
3087 |
3088 | ```javascript
3089 | vwatchImmediate(${1:source}, (${2:val}) => {
3090 | $0
3091 | })
3092 | ```
3093 |
3094 | |
3095 |
3096 |
3097 |
3098 | vwatchPausable |
3099 | VueUse watchPausable |
3100 |
3101 |
3102 | ```javascript
3103 | const { stop$3, pause$4, resume$5 } = watchPausable(${1:source}, (${2:val}) => {
3104 | $0
3105 | })
3106 | ```
3107 |
3108 | |
3109 |
3110 |
3111 |
3112 | vwatchThrottled |
3113 | VueUse watchThrottled |
3114 |
3115 |
3116 | ```javascript
3117 | watchThrottled(${1:source}, (${2:val}) => {
3118 | $0
3119 | }, { throttle: ${3:500} })
3120 | ```
3121 |
3122 | |
3123 |
3124 |
3125 |
3126 | vwatchTriggerable |
3127 | VueUse watchTriggerable |
3128 |
3129 |
3130 | ```javascript
3131 | const { trigger$3, ignoreUpdates$4 } = watchTriggerable(${1:source}, (${2:val}) => {
3132 | $0
3133 | })
3134 | ```
3135 |
3136 | |
3137 |
3138 |
3139 |
3140 | vwatchWithFilter |
3141 | VueUse watchWithFilter |
3142 |
3143 |
3144 | ```javascript
3145 | watchWithFilter(${1:source}, (${2:val}) => {
3146 | $0
3147 | }, { eventFilter: $3 })
3148 | ```
3149 |
3150 | |
3151 |
3152 |
3153 |
3154 | vwhenever |
3155 | VueUse whenever |
3156 |
3157 |
3158 | ```javascript
3159 | whenever(${1:source}, (${2:val}) => {
3160 | $0
3161 | })
3162 | ```
3163 |
3164 | |
3165 |
3166 |
3167 |
3168 | vuse:vmodel |
3169 | Implement v-model using useVModel |
3170 |
3171 |
3172 | ```javascript
3173 | const ${2:value} = useVModel(props, '${1:modelValue}', emit)
3174 | ```
3175 |
3176 | |
3177 |
3178 |
3179 |
3180 | vuse:vmodels |
3181 | Implement v-model using useVModels |
3182 |
3183 |
3184 | ```javascript
3185 | const { ${1:modelValue}$2 } = useVModels(props, emit)
3186 | ```
3187 |
3188 | |
3189 |
3190 |
3191 |
3192 | vuse:hover |
3193 | VueUse useElementHover |
3194 |
3195 |
3196 | ```javascript
3197 | const ${1:elem} = ref<${2|HTMLInputElement,HTMLDivElement,...|} | null>(null)
3198 | const ${3:isHovered} = useElementHover($1)
3199 | ```
3200 |
3201 | |
3202 |
3203 |
3204 |
3205 | vuse:fetch / vuf |
3206 | VueUse useFetch |
3207 |
3208 |
3209 | ```javascript
3210 | const { data: ${1:data} } = useFetch('$2'$3)
3211 | ```
3212 |
3213 | |
3214 |
3215 |
3216 |
3217 | vget |
3218 | VueUse get |
3219 |
3220 |
3221 | ```javascript
3222 | get($1)
3223 | ```
3224 |
3225 | |
3226 |
3227 |
3228 |
3229 | vset |
3230 | VueUse set |
3231 |
3232 |
3233 | ```javascript
3234 | set($1, $2)
3235 | ```
3236 |
3237 | |
3238 |
3239 |
3240 |
3241 | vdef |
3242 | VueUse isDefined |
3243 |
3244 |
3245 | ```javascript
3246 | isDefined($1)
3247 | ```
3248 |
3249 | |
3250 |
3251 |
3252 |
3253 | vuse:toggle / vut |
3254 | VueUse useToggle |
3255 |
3256 |
3257 | ```javascript
3258 | const [${1:value}, ${2:toggle}] = useToggle()
3259 | ```
3260 |
3261 | |
3262 |
3263 |
3264 |
3265 | vuse:toggle:fn / vutt |
3266 | VueUse useToggle function |
3267 |
3268 |
3269 | ```javascript
3270 | const toggle${2/(.*)/${1:/capitalize}/} = useToggle($1)
3271 | ```
3272 |
3273 | |
3274 |
3275 |
3276 |
3277 | vuse:import / vuim |
3278 | Import from vueuse |
3279 |
3280 |
3281 | ```javascript
3282 | import { $1 } from '@vueuse/core'
3283 | ```
3284 |
3285 | |
3286 |
3287 |
3288 |
3289 |
3290 | ### Vue Macros
3291 |
3292 |