- 文件 -> 首选项 -> 用户片段
- 选择新代码片段
- 在文件底下添加自己的代码模板
"Create vue template": {
"prefix": "vue3router",
"body": [
"import { createRouter, createWebHashHistory } from 'vue-router';",
"",
"const router = createRouter({",
" history: createWebHashHistory(),",
" routes: [",
" { path: '/', component: () => import('../views/home.vue')}",
" ]",
"})",
"",
"export default router"
],
"description": "Create vue3router template"
}
- 解释
- prefix:输入xxx,就可以提示出这段代码模板
- body:代码内容,每一行都要用双引号括起来,注意结尾要在外面加逗号,空行也要用双引号
- description:代码提示时候显示的描述