vscode用户代码片段(vue2,vue3)

vue2模板:

{
	"Print to console": {
		"prefix": "vue2",
		"body": [
			"<template>",
				"<div class=\"container\">", 
				
				"</div>",
			"</template>",
			"<script> ",
			"export default {",
				"name: '',",
				"data: function () {",
				"return {",
				" ",
				"}",
				"},",
				"watch: {",
				" ",
				"},",
				"components: {",
				" ",
				" },",
				"methods:{",
				" ",
				" },",
				"mounted: function () {",
				" ",
				"},",
				"beforeCreate: function () {",
				" ",
				"}",
			"}",
			"</script>",
			"<style scoped lang=\"scss\">", 
			" ",
			"</style>"
		],
		"description": "Log output to console"
	}
}

vue3模板:

{
	"Print to console": {
		"prefix": "vue3",
		"body": [
			"<template>",
				"<div class=\"container\">", 
				" ",
				"</div>",
            "</template>",
            "<script>",
			" ",
            "import { defineComponent, getCurrentInstance, onMounted, onBeforeMount, reactive, toRefs } from 'vue'", 
            "export default defineComponent({",
				"name:'',",
				"props: { },",
				"emits:[],",
				"components: {", 
				" ",
				"},",
				"setup(props, ctx){",
					"const { proxy } = getCurrentInstance();",
					"const state = reactive({",
					" ",
					"})",
					"onMounted(() => {",
					" ",
					"})",
					"onBeforeMount(() => {",
					" ",
					"})",
					" ",
					"return {",
						"...toRefs(state),",
						" ",
					"}",
				"}",
			"})",
            "</script>",
            "<style scoped lang=\"scss\">", 
			" ",
            "</style>",
			" "
			],
			"description": "A vue file template"
	}
}

vue3的setup语法糖:

{
	"Print to console": {
		"prefix": "v-setup",
		"body": [
		"<template>",
		"<div class=\"container\">", 
		" ",
		"</div>",
		"</template>",
		"<script setup>",
		"import { getCurrentInstance, onBeforeMount, onMounted, reactive } from 'vue'",
		"const { proxy } = getCurrentInstance();",
		"const emits = defineEmits([])",
		"const props = defineProps({",
		" ",
		"})",
		"const state = reactive({",
		" ",
		"})",

		"onBeforeMount(() => {",
		" ",
		"})",
		"onMounted(() => {",
		" ",
		"})",
		"defineExpose({ state })",
		" ",
		"</script> ",
		"<style lang=\"scss\" scoped>",
		" ",
		"</style>"
	],
	"description": "vue3"
	}
}

函数:

{
	"Print to console": {
		"scope": "javascript,typescript",
		"prefix": "cfun",
		"body": [
			"const func$1 = () => {",
			"$0",
			"}"
		],
		"description": "Log output to console"
	}
}
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
对于VSCode中的Vue2代码补全插件,可以使用以下插件来提供代码补全功能: 1. Vetur - Vetur是一个功能强大的插件,提供语法高亮、智能感知、Emmet等功能,并且包含格式化功能。通过快捷键Alt Shift F可以格式化全文,Ctrl K Ctrl F可以格式化选中的代码。 2. JavaScript(ES6) code snippets - 这个插件提供了ES6语法的智能提示和快速输入功能,除了支持js文件外,还支持.ts,.jsx,.tsx,.html,.vue等文件。省去了配置支持各种包含js代码的文件的时间。 3. Auto Complete Tag - 这个插件可以自动补全HTML代码,尤其适用于编写Vue模板。 以上是几个常用的VSCode插件,可以帮助提供Vue2代码补全功能。<span class="em">1</span><span class="em">2</span> #### 引用[.reference_title] - *1* [vue2 vscode需要安装的插件](https://blog.csdn.net/lx6091543wwwcctv/article/details/131072827)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [VSCodeVue3初识.docx](https://download.csdn.net/download/zhoujian_911/86720497)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值