Chao's Blog Chao's Blog
首页
  • vue

    • vue路由
  • 学习笔记

    • 《JavaScript教程》
    • 《JavaScript高级程序设计》
    • 《ES6 教程》
    • 《Vue》
    • 《React》
    • 《TypeScript 从零实现 axios》
    • 《Git》
    • TypeScript
    • JS设计模式总结
  • java
  • spring
  • springboot
  • springcloud
  • git
  • maven
  • nginx
  • tomcat
  • springmvc
  • jvm
  • 图数据库
  • mysql数据库
  • redis数据库
  • windows下docker安装nginx并挂载目录
  • linux命令
  • linux安装软件
  • linux脚本
  • idea
  • vscode
  • 归档
  • 综合项目

    • 若依项目
    • mall项目
  • java
  • mybatis
  • xxl-job
  • mybatis
GitHub (opens new window)

~chao

永远菜鸟,不断努力~
首页
  • vue

    • vue路由
  • 学习笔记

    • 《JavaScript教程》
    • 《JavaScript高级程序设计》
    • 《ES6 教程》
    • 《Vue》
    • 《React》
    • 《TypeScript 从零实现 axios》
    • 《Git》
    • TypeScript
    • JS设计模式总结
  • java
  • spring
  • springboot
  • springcloud
  • git
  • maven
  • nginx
  • tomcat
  • springmvc
  • jvm
  • 图数据库
  • mysql数据库
  • redis数据库
  • windows下docker安装nginx并挂载目录
  • linux命令
  • linux安装软件
  • linux脚本
  • idea
  • vscode
  • 归档
  • 综合项目

    • 若依项目
    • mall项目
  • java
  • mybatis
  • xxl-job
  • mybatis
GitHub (opens new window)
  • idea

  • vscode

    • vscode中生成vue3.0代码片段
      • vscode中生成vue2.0代码片段
    • 开发工具
    • vscode
    ~chao
    2022-11-18
    目录

    vscode中生成vue3.0代码片段

    # vscode中生成vue3.0代码片段

    1、 首先在vscode编辑器中打开,【文件】–>【首选项】–>【用户片段】–>选择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"
    	// }
    	"vue3": {
    		"prefix": "vue3",
    		"body": [
    				"<template>",
    				"    <div>\n",
    				"    </div>",
    				"</template>\n",
    				"<script lang='ts'>",
    			"import { defineComponent,reactive, toRefs, onBeforeMount, onMounted } from 'vue';",
    			"import { useRoute, useRouter } from 'vue-router';",
    			"export default defineComponent({",
    			"    name: 'index',",
    			"    setup(props, context) {",
    			"    const route = useRoute();",
    			"    const router = useRouter();",
    			"    console.log('1-开始创建组件-setup')",
    			"    const state = reactive({\n",
    			"    })",
    			"    const funcList = {",
    			"        getInfo() {}",
    			"    }",
    			"    onBeforeMount(() => {",
    			"        console.log('2.组件挂载页面之前执行----onBeforeMount')",
    			"    })",
    			"    onMounted(() => {",
    			"        funcList.getInfo();",
    			"        console.log('3.-组件挂载到页面之后执行-------onMounted')",
    			"    })",
    			"    return {",
    			"        ...toRefs(state),",
    			"        ...funcList",
    			"    }",
    			"  },",
    			"}",
    			"</script>",
    			"<style scoped lang='scss'>\n",
    			"</style>",
    		],
    		"description": "Log output to console"
    	}	
    }
    
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56

    2、新建.vue结尾的文件,输入vue3 有提示,生成片段

    编辑 (opens new window)
    上次更新: 2024/01/26, 05:03:22
    idea快捷键
    vscode中生成vue2.0代码片段

    ← idea快捷键 vscode中生成vue2.0代码片段→

    最近更新
    01
    python使用生成器读取大文件-500g
    09-24
    02
    Windows环境下 Docker Desktop 安装 Nginx
    04-10
    03
    使用nginx部署多个前端项目(三种方式)
    04-10
    更多文章>
    Theme by Vdoing | Copyright © 2022-2024 chaos | MIT License
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式