アプローチ 1: vscode で順番に開きます: [ファイル] --> [環境設定] --> [ユーザー コード スニペットの構成] --> [新しいコード スニペット]
アプローチ 2: または、左下隅にある設定ボタンをクリックして見つけます (以下を参照)
次に、vue.json をクリックします。
設定されていない場合は、下の図のように表示されます。設定されている場合は、次の手順も表示されます。
次のコードを貼り付けます
{
// Place your snippets for vue here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log", //log为快捷名称
// "body": [
// "console.log('$1');",//body中就是输入快捷名称并且选择时快捷生成的代码模板
// "$2"
// ],
// "description": "Log output to console"
// }
"Print to console": {
"prefix": "vue3",
"body": [
"<template>",
" <div></div>",
"</template>",
"",
"<script setup>",
"import { ref, reactive, getCurrentInstance } from 'vue';",
"const { proxy } = getCurrentInstance()",
"</script>",
"",
"<style scoped lang='scss'>",
"</style>"
],
"description": "Log output to console"
}
}
ショートカット キー: ctrl+s; ファイルを保存して使用します。
vue3 を選択すると、以下に示すように、コード テンプレートの本文にコードをすばやく生成できます。
これで完了です。
研究の問題点を記録するためだけに