Optimizing the development experience: mastering the skills and methods of configuring Vue templates in VSCode

foreword

When you use VSCode to configure vue templates, you will find that it is like a caring assistant. This article will introduce how to use VSCode to configure vue templates to make your code more efficient and beautiful. Let's take a look together.


1. Open the VSCode console

File --> Preferences --> User Snippets

insert image description here

or

Ctrl + Shift + P

insert image description here


2. Find "Preferences: Configure User Code Snippets"

insert image description here

click to enter

insert image description here


3. After entering vue, click on the vue.json file

insert image description here


4. Configuration template

Open the configuration generation address , copy the template to the left, and the configuration template will be generated on the right.

insert image description here

5. Copy the configuration template to vue.json

{
    
    
    "vue-template": {
    
    
        "prefix": "vue",
        "body": [
            "<template>",
            "  <div class=\"\">",
            "",
            "  </div>",
            "</template>",
            "",
            "<script>",
            "export default {",
            "  data() {",
            "    return {}",
            "  },",
            "}",
            "</script>",
            "",
            "<style scoped lang=\"scss\">",
            "</style>"
        ],
        "description": "vue-template"
    }
}

6. Use

Create a new page and enter vueEnter to automatically generate a template.

insert image description here

Of course, you can also add two templates as follows:

{
    
    
    "vue-template": {
    
    
        "prefix": "vue",
        "body": [
            "<template>",
            "  <div class=\"\">",
            "",
            "  </div>",
            "</template>",
            "",
            "<script>",
            "export default {",
            "  data() {",
            "    return {}",
            "  },",
            "}",
            "</script>",
            "",
            "<style scoped lang=\"scss\">",
            "</style>"
        ],
        "description": "vue-template"
    },
    "vue-templateTwo": {
    
    
        "prefix": "vue2",
        "body": [
            "<template>",
            "  <div class=\"\">",
            "",
            "  </div>",
            "</template>",
            "",
            "<script>",
            "export default {",
            "  data() {",
            "    return {}",
            "  },",
            "  mounted() {},",
            "  methods: {},",
            "}",
            "</script>",
            "",
            "<style scoped lang=\"scss\">",
            "</style>"
        ],
        "description": "vue-templateTwo"
    }
}

use

insert image description here

おすすめ

転載: blog.csdn.net/Shids_/article/details/131571857