VS code 设置vue文件模版

    技术2022-07-14  66

    进入User Snippets

    方法一: File --> Preferences --> User Snippets 方法二:左下角齿轮 —> User Snippets

    进入设置

    在User Snippets 里输入vue, 选择 vue.json (有的vscode 版本是vue),进入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", // "body": [ // "console.log('$1');", // "$2" // ], // "description": "Log output to console" // } "vue template":{ "prefix":"vue", "body":[ "<template>", "<div ></div>", "</template>", "<script>", "export default {", "name:'$1',", "filters:{},", "components: {},", "mixins:[],", "data() {", "return {}", "},", "computed: {},", "watch: {},", "beforeCreate() {},", "created() {", "},", "beforeMount() {},", "mounted() {", "},", "beforeUpdate() {},", "updated() {}, ", "beforeDestroy() {},", "destroyed() {},", "activated() {},", "methods: {}", "}", "</script>", "<style lang='scss' scoped>", "</style>" ], "description": "vue template" } }

    使用

    在新建的vue文件里,输入 vue, 再按回车,即生成模版内容

    Processed: 0.012, SQL: 10