当前位置: 首页 > news >正文

vue3模板-vscode设置(语法糖)

选择菜单里的 文件 > 首选项 > 用户代码片段
vscode模板

{"Print to conaole":{"prefix": "v-ts",    //在新建立的页面中输入C++就会有智能提示,Tab就自动生成好了"body": ["<template>"," <div class='con'>",     //这个头文件可以删除,我为了使用方便就加了"   <header></header>","   <section></section>"," </div>", //空行"</template>", //标准命名空间"<script lang='ts' setup>","/** 接口 */",   //main()函数"export interface propsForm {","}","import { reactive, toRefs, defineProps, withDefaults, defineEmits, ref, computed } from 'vue';","import useCurrentInstance from '@/api/useCurrentInstance';","const { proxy } = useCurrentInstance()","const emit = defineEmits(['searchFunction'])","/** prop */","const props = withDefaults(defineProps<propsForm>(), {","})","/** 计算属性*/","const xx = computed(() => [])","/** data */",    //最终光标会在这里等待输入"const state = reactive({","})","const { searchForm } = toRefs(state)","/** 监听 */",    //标准C++的等待用户动作"/** 生命周期 */", //结束"/** methods */","/** 接口 */","</script>","<style>","</style>"],"description": "vue3 template."   //用户输入后智能提示的内容(你可以用中文写“生成C++模板”)}
}

结果

<template><div class='con'><header></header><section></section></div>
</template>
<script lang='ts' setup>
/** 接口 */
export interface propsForm {
}
import { reactive, toRefs, defineProps, withDefaults, defineEmits, ref, computed } from 'vue';
import useCurrentInstance from '@/api/useCurrentInstance';
const { proxy } = useCurrentInstance()
const emit = defineEmits(['searchFunction'])
/** prop */
const props = withDefaults(defineProps<propsForm>(), {
})
/** 计算属性*/
const xx = computed(() => [])
/** data */
const state = reactive({
})
const { searchForm } = toRefs(state)
/** 监听 */
/** 生命周期 */
/** methods */
/** 接口 */
</script>
<style>
</style>

useCurrentInstance.ts

import { ComponentInternalInstance, getCurrentInstance } from 'vue'
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default function useCurrentInstance() {const { appContext } = getCurrentInstance() as ComponentInternalInstanceconst proxy = appContext.config.globalPropertiesreturn {proxy}
}
http://www.lryc.cn/news/190887.html

相关文章:

  • RFID超高频读写器的特点和应用
  • 诡异事件:开发的安卓摄像头应用突然不能保存图片,回滚代码都查不出来
  • validator库的使用详解
  • ADS版图中连接提示线设置
  • 【MySQL】内置函数——数学函数+其他函数
  • Ubuntu 23.10 Beta 镜像开放下载
  • mybatispagehelp嵌套分页处理
  • 增速波动!W「下」AR「上」!HUD前装供应商比拼硬核能力
  • XXE漏洞复现实操
  • github创建个人网页登录后404无法显示的问题
  • MySQL——源码安装教程(初版)
  • 1.1.C++项目:仿muduo库实现并发服务器之any类的设计
  • linux项目启动脚本start.sh和stop.sh停止脚本
  • Avalonia常用小控件Svg
  • 设计模式-行为型模式
  • 【EventLoop】问题一次搞定
  • Unity中Shader光照模型Phong
  • 消息队列缓存,以蓝牙消息服务为例
  • MSF派生给另外MSF,meterpreter派生给另外meterpreter,Metasploit
  • 【LeetCode】1.两数之和
  • 3. Windows下C++/MFC调用hiredis库操作redis示例
  • 200、使用默认 Exchange 实现 P2P 消息 之 消息生产者(发送消息) 和 消息消费者(消费消息)
  • SqlServer--get 和 post 请求 http接口
  • 利用人工智能提升企业培训的个性化体验
  • 基于JavaWeb的图书售卖网站(源码+部署+LW)
  • Java设计模式之代理模式
  • Oracle数据泵导入和导出命令
  • Linux中所有环境变量配置文件及用途
  • 一文读懂flutter线程: 深入了解Flutter中的多线程编程
  • 如何限制word文件中部分内容无法编辑