1. 打开工具——左侧选择扩展搜索vue-helper插件安装
在这里插入图片描述

2. 进入文件——首选项——用户片段——输入选择Vue.json

在这里插入图片描述
在这里插入图片描述

3. 编辑vue.json

prefix 前缀,可自定义,用于快捷创建模板代码

在这里插入图片描述

4. 使用:新建Vue文件,输入vue然后tab
在这里插入图片描述

在这里插入图片描述
Tip 创建多个模板格式

{
	"create Vue2":...,
	"create Vue3 Setup":...,
	...
}

【常用模板】

//Vue2 —— 通用
{
	"create Vue2": {
		"prefix": "vue",
		"body": [
			"<template>",
			"  <div></div>",
			"</template>\n",
			"<script>",
			"  export default {",
			"    data(){",
			"      return{}",
			"    },",
			"    methods:{},",
			"    created(){},",
			"    mounted(){}",
			" }",
			"</script>\n",
			"<style lang=scss>",
			"</style>",
		],
		"description": "Log output to console"
	}
}
//Vue2 —— vue-property-decorator
{
	"create Vue2 vue-property-decorator": {
		"prefix": "vue",
		"body": [
			"<template>",
			"  <div></div>",
			"</template>\n",
			"<script lang=ts>",
			"  import { Vue , Component } from 'vue-property-decorator'",
			"  @Component({",
			"    components: {},",
			"    filters: {},",
			"    name: '',",
			"  })\n",
			"  export default class Name extends Vue {",
			"  }",
			"</script>\n",
			"<style lang=scss>",
			"</style>"
		],
		"description": "Log output to console"
	}
}
//Vue3 —— setup
{
	"create Vue3 Setup": {
		"prefix": "vue",
		"body": [
			"<template>",
			"  <div></div>",
			"</template>\n",
			"<script lang=ts>",
			"  import { defineComponent} from 'vue'\n",
			"  export default defineComponent({",
			"    name: '',",
			"    props: {},",
			"    components: {},",
			"    setup: () => {}",
			"  })",
			"</script>\n",
			"<style lang=scss>",
			"</style>"
		],
		"description": "Log output to console"
	}
}
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐