打開 設(shè)置-首選項(xiàng)-user Snippets
選擇new global snippets 一個(gè)新的全局代碼片段
提供的默認(rèn)的案例如下:
// Example:
"Print to console": {
"scope": "javascript,typescript",
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
}
scope:表示代碼作用范圍串慰,建議刪掉此屬性以作用全局,
prefix:設(shè)置快捷命令
body:代碼內(nèi)容
description:代碼描述
vue3快捷代碼示例:
"Print to console": {
"prefix": "vv3",
"body": [
"<template>",
"</template>",
"<script lang=\"ts\">",
"import { defineComponent } from \"vue\";",
"export default defineComponent({",
"name: 'App',",
"components: {},",
"setup() {return {}},",
"});",
"</script>",
"<style scoped></style>",
],
"description": "Log output to console"
}
代碼片段文件存儲(chǔ)在用戶目錄下
以window為例:C:\Users\用戶\AppData\Roaming\Code\User\snippets
也可直接在用戶目錄下修改文件