vscode中快速生成vue3模板

vscode中快速生成vue3模板

可以根据实际情况修改,有用记得点赞
1.首先在vscode编辑器中

文件–>首选项–>用户片段–>点击新建代码片段–取名vue.json 确定

2.把下列代码放进去

{
	"Print to console": {
		"prefix": "vue3",
		"body": [
			"<!-- $0 -->",
			"<template>",
			"  <div></div>",
			"</template>",
			"",
			"<script lang='ts'>",
			"import { reactive,toRefs,onBeforeMount,onMounted} from 'vue'",
			"interface DataProps {}",

			"export default {",
			"    name: '',",
			"      setup() {",
			"          console.log('1-开始创建组件-setup')",
			"          const data: DataProps = reactive({",
			""            ,
			"          })",
			"          onBeforeMount(() => {",
			"              console.log('2.组件挂载页面之前执行----onBeforeMount')",
			"          })",
			"          onMounted(() => {",
			"              console.log('3.-组件挂载到页面之后执行-------onMounted')",
			"          })",
			"          const refData = toRefs(data);",
			"          return {",
			"              ...refData,",
			"          }",
			""  ,
			"      }",
			"  };",
			"</script>",
			"<style scoped>",
			"</style>",
	],
		"description": "Log output to console"
	}
}

3.新建.vue结尾的文件,输入vue3 按键盘的tab自动生成模板

<!--  -->
<template>
  <div></div>
</template>

<script lang='ts'>
import { reactive,toRefs,onBeforeMount,onMounted} from 'vue'
interface DataProps {}
export default {
    name: '',
      setup() {
          console.log('1-开始创建组件-setup')
          const data: DataProps = reactive({

          })
          onBeforeMount(() => {
              console.log('2.组件挂载页面之前执行----onBeforeMount')
          })
          onMounted(() => {
              console.log('3.-组件挂载到页面之后执行-------onMounted')
          })
          const refData = toRefs(data);
          return {
              ...refData,
          }

      }
  };
</script>
<style scoped>
</style>

参考网址:

https://blog.csdn.net/qq_43373320/article/details/110368849

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值