VSCODE配置用户代码片段

95 阅读1分钟
{
	// 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:
	"打印": {
		"prefix": "cl",
		"body": [
			"console.log($1)"
		],
	},
  "for循环": {
    "prefix": "for",
    "body": [
      "for (let i = 0; i <= arr.length -1; i++) {",
      "  $1",
      "}"
    ],
  },
  "事件监听": {
    "prefix": "ad",
    "body": [
      "document.addEventListener('click', function () {",
      "  $1",
      "})"
    ],
  },
  "获取元素": {
    "prefix": "qs",
    "body": [
      "const ele = document.querySelector('.$1')"
    ]
  },
  "jq入口函数": {
    "prefix": "jq",
    "body": [
      "$(function () {",
      "  $('$1')",
      "})"
    ]
  }
}