1. Create a configuration file:
First, open VSCode
, Ctrl+Shift+P
, open the search box:
Second, enter: user
, and click inSnippets:Configure User Snippets
Third, enter vue3js
and press Enter:
Fourth, open the project and find the configuration file vue3js.code-snippets
:
2. Configure shortcuts:
First, vue3js.code-snippets
enter the configuration information in the configuration file:
// 此时生成的代码模板中,只有单引号;
{
"Print to console": {
"prefix": "v3js",
"body": [
"<template>",
" <div></div>",
"</template>",
"",
"<script setup>",
"import { ref, reactive } from 'vue'",
"",
"</script>",
"",
"<style lang='scss' scoped>",
"",
"</style>",
],
"description": "Log output to console"
}
}
// 此时生成的代码模板中,双引号的展示方法(即:模板中展示双引号);
{
"Print to console": {
"prefix": "v3js",
"body": [
"<template>",
" <div></div>",
"</template>",
"",
"<script setup>",
"import { ref, reactive } from \"vue\"",
"",
"</script>",
"",
"<style lang=\"scss\" scoped>",
"",
"</style>",
],
"description": "Log output to console"
}
}
Second, vue3js.code-snippets
interpretation of configuration information:
A. “prefix”
Attribute refers to: the name of the generated template;
After the configuration is completed, in the . vue
file, enter the string and click Enter to generate the defined template (ie: vue3js.code-snippets
the information configured in );
B. “body”
Attribute refers to: the code template to be generated;
You can assign corresponding code templates according to your actual needs;
3. Test shortcuts:
First, the testing process:
// At this time, .vue
enter the shortcut key in : , and then press Enter, the template configured in v3js
will be displayed on the page ;vue3js.code-snippets
Second, vue
another way to configure template shortcuts:
A. Create .vscode
the file directly in the project:
B. .vscode
Create a file in the folder vue3js.code-snippets
and add the configured vue
template information:
4. Summary:
First, if there is anything wrong or inappropriate, please give me some pointers and exchanges!
Second, if you forward or quote the content of this article, please indicate the address of this blog ( 直接点击下面 url 跳转
) https://blog.csdn.net/weixin_43405300 . Creation is not easy, but it must be done and cherished!
Third, if you are interested, you can pay more attention to this column (Vue (Vue2+Vue3) essential column for interviews) ( 直接点击下面 url 跳转
): https://blog.csdn.net/weixin_43405300/category_11525646.html?spm=1001.2014.3001.5482