vue3.code-snippets 1015 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. {
  2. "Vue3 Component": {
  3. "scope": "vue",
  4. "prefix": "vue3",
  5. "description": "Vue3 + TypeScript 组件模板",
  6. "body": [
  7. "<!--",
  8. " @desc: $1",
  9. " @date: ${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}",
  10. "-->",
  11. "",
  12. "<template>",
  13. " <div class=\"$TM_FILENAME_BASE\">{{ title }} </div>",
  14. "</template>",
  15. "",
  16. "<script setup lang=\"ts\">",
  17. " /** -------------------- 组件参数 -------------------- */",
  18. " interface Props {",
  19. " title?: string",
  20. " }",
  21. " const props = withDefaults(defineProps<Props>(), {",
  22. " title: 'hello'",
  23. " })",
  24. "",
  25. " /** -------------------- 生命周期 ----------------------- */",
  26. " onMounted(() => {",
  27. " console.log(`${props.title} mounted`)",
  28. " })",
  29. "</script>",
  30. "",
  31. "<style scoped lang=\"scss\">",
  32. " .${TM_FILENAME_BASE} {",
  33. " padding: 10px;",
  34. " }",
  35. "</style>",
  36. ""
  37. ]
  38. }
  39. }