vscode用户片段的快乐使用,动手实现一个自己的snippets

  • 文件-首选项-用户片段
  • 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"
    },
    "Print to vue_fast_all":{
    
    
        "prefix": "vue",
        "body": [
            "<template>",
            "  <div class='className'>",
            "  $1",
            "  </div>",
            "</template>",

            "<script>",
            "export default {",
            "  name: 'className',",
            "  components: {},",
            "  props: {",
            "  // props: {",
            "  //   type: String",
            "  // }",
            "  },",
            "  data() {",
            "    return {",
            " ",
            "    };",
            "  },",
            "  computed: {},",
            "  created() {},",
            "  mounted() {},",
            "  methods: {},",
            "  watch: {}",
            "  };",
            "</script>",

            "<style lang='scss' scoped>",
            ".className{",
            "    background: #fff;",
            "}",
            "</style>" ,
        ],
        "description": "vue fast full skeleton"
    },
}
  • javascript.json
{
    
    
	// Place your snippets for javascript 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_deep":{
    
    
            "prefix": "clod",
            "body": [
              "console.log('$1', JSON.parse(JSON.stringify($1)))"
            ],
            "description": "console_deep 一个简单的深拷贝,实现打印数据的直观展示,解决查看对象,数组值需要鼠标一个一个点击的麻烦问题"
    },
    "Print to console.group()":{
    
    
            "prefix": "clge",
            "body": [
              "console.group('$1');",
              "$2",
              "console.groupEnd();",
            ],
            "description": "console.group()"
    },
	// "Print to console": {
    
    
	// 	"prefix": "log",
	// 	"body": [
	// 		"console.log('$1');",
	// 		"$2"
	// 	],
	// 	"description": "Log output to console"
	// }
}

猜你喜欢

转载自blog.csdn.net/weixin_45844049/article/details/113974662