前言:软件为vscode,第一个代码块是H5初始代码块,后面是JS代码块,要想使用,得学会简单的用户代码片段设置,这是以后一直用得到的,也非常好用,例如输入 9h ,可以生成自定义的初始化页面,节省自己的时间,增加效率。
"html:5": {
"prefix": "9h",
"body": [
"<!DOCTYPE html>",
"<html lang=\"en\">",
"",
"<head>",
"\t<meta charset=\"UTF-8\">",
"\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">",
"\t<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">",
"\t<title>多练多思考,先肯定再认可</title>",
"",
"</head>",
"",
"<body>",
"",
"\t<script>",
"\t\t$0",
"\t</script>",
"</body>",
"",
"</html>",
],
"description": "HTML5"
},
JavaScript
"箭头函数": {
"prefix": "fn",
"body": "($1) => {$0}",
"description": "ES6 箭头函数",
},
"console.log": {
"prefix": "log",
"body": [
"console.log($1)",
"$2"
],
"description": "console.log快捷",
},
"方法注释": {
"prefix": "zs-Function",
"body": [
"/**",
" * @param name... { ${1|Boolean,Number,String,Object,Array|} }",
" * @description description...",
" * @return name... { ${2|Boolean,Number,String,Object,Array|} }",
" */",
"$0"
],
"description": "添加方法注释"
},
"作者和时间注释": {
"prefix": "zs-Author & Time",
"body": [
"/**",
" * Created by preference on $CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE",
" */",
"$0"
],
"description": "添加作者和时间注释"
},
"Vue模板": {
"prefix": "vue-template",
"body": [
"<template>",
" <section class=\"$TM_FILENAME_BASE\">",
" $1",
" </section>",
"</template>\n",
"<script>",
"export default {",
" name: '$TM_FILENAME_BASE',",
" data() {",
" return {\n",
" }",
" },",
" components: {},",
" watch: {},",
" mounted() {},",
" methods: {}",
"}",
"</script>\n",
"<style scoped lang=\"less\">\n",
"</style>",
"$0"
],
"description": "Vue模板"
},
"根据id获取元素": {
"prefix": "byid",
"body": [
"document.getElementById('$1');"
],
"description": "根据id获取元素"
},
"根据标签名获取元素": {
"prefix": "bytag",
"body": [
"document.getElementsByTagName('$1');"
],
"description": "根据标签名获取元素"
},
"根据类名获取元素": {
"prefix": "byclass",
"body": [
"document.getElementsByClassName('$1');"
],
"description": "根据类名获取元素"
},
"h5获取元素": {
"prefix": "qse",
"body": [
"document.querySelector('$1');"
],
"description": "h5获取元素"
},
"h5获取所有": {
"prefix": "qseall",
"body": [
"document.querySelectorAll('$1');"
],
"description": "h5获取元素"
},
"Print to console": {
"prefix": "csl",
"body": [
"console.log($0);"
],
"description": "console.log()"
},
"alert": {
"prefix": "al",
"body": [
"alert('$0');"
],
"description": "alert"
},
"document.write": {
"prefix": "dw",
"body": [
"document.write('$0');"
],
"description": "document.write"
},
"prompt": {
"prefix": "po",
"body": [
"prompt('$0');"
],
"description": "prompt"
},
"confirm": {
"prefix": "cf",
"body": [
"confirm('$0');"
],
"description": "confirm"
},
"getElementById": {
"prefix": "dgi",
"body": [
"document.getElementById('$1')"
],
"description": "getElementById"
},
"do-while": {
"prefix": "dow",
"body": [
"do {",
"\t$0",
"} while();"
],
"description": "do-while"
},
"new Array": {
"prefix": "newa",
"body": [
"new Array($0)"
],
"description": "new Array"
},
"arr3": {
"prefix": "a3",
"body": [
"let arr = [1,2,3]"
],
"description": "arr3"
},
"arr5": {
"prefix": "a5",
"body": [
"let arr = [1,2,3,4,5]"
],
"description": "arr5"
},
"arr10": {
"prefix": "a10",
"body": [
"let arr = [1,2,3,4,5,6,7,8,9,10]"
],
"description": "arr10"
},
"forarr": {
"prefix": "fori",
"body": [
"for(let i = 0;i < $1.length;i++) {",
"\t$0",
"}"
],
"description": "arr10"
},
"forar": {
"prefix": "forj",
"body": [
"for(let j = 0;j < $1.length;j++) {",
"\t$0",
"}"
],
"description": "arr10"
},
"optc": {
"prefix": "optc",
"body": [
"Object.prototype.toString.call($0)"
],
"description": "optc"
},
"new Obj": {
"prefix": "newo",
"body": [
"new Object();"
],
"description": "new Obj"
},
"getEleById": {
"prefix": "dgi",
"body": [
"document.getElementById('$0')"
],
"description": "getElementById"
},
"getEleByTag": {
"prefix": "dgt",
"body": [
"document.getElementsByTagName('$0')"
],
"description": "getElementByTag"
},
"getEleByClass": {
"prefix": "dgc",
"body": [
"document.getElementsByClassName('$0')"
],
"description": "getElementByClass"
},
"queryselector": {
"prefix": "doq",
"body": [
"document.querySelector('$0')"
],
"description": "querySelector"
},
"querySelectorAll": {
"prefix": "doa",
"body": [
"document.querySelectorAll('$0')"
],
"description": "querySelectorAll"
},
"onload": {
"prefix": "wod",
"body": [
"window.onload = function () {",
"\t$0",
"}"
],
"description": "window.onload"
},
"for": {
"prefix": "fo",
"body": [
"for(let i = 0;i < $0;i++) {",
"\t",
"}"
],
"description": "for"
},
"documentCreate": {
"prefix": "doc",
"body": [
"document.createElement('$0')"
],
"description": "doc"
},
"getStyle": {
"prefix": "wgs",
"body": [
"window.getComputedStyle($0,null)['']"
],
"description": "wgs"
},
"event": {
"prefix": "ew",
"body": [
"e = window.event || e"
],
"description": "window.event"
}