Skip to content

Commit cb2ce7e

Browse files
authored
vscode vue3 setup snippet
1 parent 7e146d3 commit cb2ce7e

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

.vscode/sample-snippets.code-snippets

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,52 @@
88
"Vue3 setup in tag": {
99
"scope": "vue",
1010
"prefix": ["v3-setup"],
11-
"body": ["<script setup>", "import { ref, reactive, toRefs, onMounted, onUnmounted, watch } from 'vue'", "$0", "</script>\r\n", "<template>\r\n", "</template>\r\n", "<style lang=\"css\" scoped>\r\n", "</style>"],
11+
"body": [
12+
"<script setup>",
13+
"import { ref, reactive, computed, watch, toRefs, onMounted, onUnmounted } from 'vue'",
14+
"import { RouterLink, useRouter, useRoute } from 'vue-router'",
15+
"import { useAuthStore } from '../stores/auth.js'",
16+
"import { useI18n } from 'vue-i18n'",
17+
"const { t, locale, availableLocales } = useI18n({ useScope: 'global' })",
18+
"const emits = defineEmits(['update:modelValue', 'change'])",
19+
"const props = defineProps({ label: { type: String, required: true, default: 'Label' }, })",
20+
"const store = useAuthStore()",
21+
"const route = useRoute()",
22+
"let input = ref(null)",
23+
"let password = ref('')",
24+
"const checked = computed(() => { return props.modelValue + 1 })",
25+
"onMounted(() => {",
26+
"input.value.focus()",
27+
"console.log('Current locale', locale.value, availableLocales)",
28+
"store.changeLocale(route.query.locale)",
29+
"store.activateUser(route.params.id, route.params.code)",
30+
"})",
31+
"function onSubmit(e) {",
32+
" store.scrollTop()",
33+
" store.loginUser(new FormData(e.target))",
34+
"}",
35+
"watch(() => locale.value, (lang) => { store.changeLocale(lang) })",
36+
"</script>",
37+
"<template>",
38+
" <router-link to=\"/\"><img class=\"float-left auth-logo\" src=\"@/assets/images/auth-logo.png\" height=\"70\" /></router-link>",
39+
" <router-link to=\"/login\" class=\"link-left\">{{ $t('change_password.Have_an_account') }}</router-link>",
40+
"$0",
41+
"<form @submit.prevent=\"onSubmit\" class=\"form-auth\">",
42+
" <input ref=\"input\" v-model=\"password\" name=\"password\">",
43+
" <button class=\"button\" :title=\"$t('change_password.Change')\">{{ $t('change_password.Change') }}</button>",
44+
"</form>",
45+
"</template>",
46+
"<style>",
47+
"@import './css/root.css';",
48+
"[color-scheme='dark'] {",
49+
" color-scheme: dark;",
50+
" --logo: url('@/assets/images/auth-logo-dark.png');",
51+
"}",
52+
"</style>",
53+
"<style lang=\"css\" scoped>",
54+
"@import './css/auth.css'",
55+
"</style>"
56+
],
1257
"description": "Vue3 setup in tag"
1358
},
1459
"Php if": {

0 commit comments

Comments
 (0)