{
// ---------------------------------js基础--------------------
"console": {
"prefix": "cl",
"body": ["console.log($1)"]
},
"alert": {
"prefix": "al",
"body": ["alert($1)"]
},
"write": {
"prefix": "dw",
"body": ["document.write($1)"]
},
"prompt": {
"prefix": "pr",
"body": ["prompt('$1')"]
},
"push": {
"prefix": "pus",
"body": ["$1.push()"]
},
"splice": {
"prefix": "spli",
"body": ["$1.splice()"]
},
"unshift": {
"prefix": "unsh",
"body": ["$1.unshift()"]
},
"shift": {
"prefix": "shi",
"body": ["$1.shift()"]
},
"pop": {
"prefix": "pop",
"body": ["$1.pop()"]
},
"join": {
"prefix": "join",
"body": ["$1.join('')"]
},
"sort": {
"prefix": "sort",
"body": ["$1.sort(function (a, b){ return a - b //升序 })"]
},
"for循环-正序": {
"prefix": "fo",
"body": ["for (let i = 0; i < $1.length; i++ ){", "\t", "}"]
},
"for循环-数字": {
"prefix": "f0",
"body": ["for (let i = 1; i <= $1; i++ ){", "\t", "}"]
},
"for循环-正序-j": {
"prefix": "foj",
"body": ["for (let j = 0; j < $1.length; j++ ){", "\t", "}"]
},
"for循环-倒叙": {
"prefix": "foo",
"body": ["for (let i = $1.length-1; i >= 0; i--){", "\t", "}"]
},
"for-in": {
"prefix": "forin",
"body": ["for (let k in $1){", "\t", "}"]
},
"if-else": {
"prefix": "ifel",
"body": ["if ($1) {", "\t", "} else{", "\t", "}"]
},
"switch": {
"prefix": "swit",
"body": ["switch(数据){case 值1:代码1 break default:代码n break}"]
},
"function": {
"prefix": "fun",
"body": ["function $1() {", "\t", "}"]
},
"mapfun": {
"prefix": "maf",
"body": ["$1.map(function(item, index){", "\t", "})"]
},
// 随机数
"Math.random": {
"prefix": "mathr",
"body": ["parseInt(Math.random() * $1.length)"],
"description": "按照数组内容数据生成随机数"
},
"getRandom": {
"prefix": "getr",
"body": [
"function getRandom(N, M) {return parseInt(Math.random() * (M - N + 1)) + N}"
],
"description": "按照公式生成随机数"
},
// 延时器
"getTime": {
"prefix": "getti",
"body": [
"//小时:h = parseInt(总秒数 / 60 / 60 % 24) //分钟:m = parseInt(总秒数 / 60 % 60) //秒数:s = parseInt(总秒数 % 60) "
],
"description": "计算时分秒公式"
},
// 获取时分秒
"getday": {
"prefix": "getday",
"body": [
"//天:d = parseInt(总秒数/ 60/60 /24); 小时:h = parseInt(总秒数 / 60 / 60 % 24) //分钟:m = parseInt(总秒数 / 60 % 60) //秒数:s = parseInt(总秒数 % 60) "
],
"description": "计算天时分秒公式"
},
// -------------------------------------------js基础----------------------
// -------------------------------------------属性------------------------
"disabled": {
"prefix": "dis",
"body": ["disabled"]
},
"display": {
"prefix": "di",
"body": ["display"]
},
"opacity": {
"prefix": "opa",
"body": ["opacity"]
},
"transform": {
"prefix": "trf",
"body": ["transform"]
},
"translate": {
"prefix": "trl",
"body": ["translate()"]
},
"relative": {
"prefix": "rela",
"body": ["relative"]
},
"absolute": {
"prefix": "abso",
"body": ["absolute"]
},
"fixed": {
"prefix": "fix",
"body": ["fixed"]
},
"boolean": {
"prefix": "bool",
"body": ["boolean"]
},
"undefined": {
"prefix": "undef",
"body": ["undefined"]
},
"break": {
"prefix": "break",
"body": ["break"]
},
"continue": {
"prefix": "conti",
"body": ["continue"]
},
"default": {
"prefix": "def",
"body": ["default"]
},
"history": {
"prefix": "his",
"body": ["history"]
},
"export": {
"prefix": "exp",
"body": ["export"]
},
"family": {
"prefix": "fam",
"body": ["family"]
},
"debounce": {
"prefix": "deb",
"body": ["debounce"]
},
"throttle": {
"prefix": "th",
"body": ["throttle"]
},
"constructor": {
"prefix": "cons",
"body": ["constructor"]
},
"currentTime": {
"prefix": "curr",
"body": ["video.currentTime"]
},
"e.target.tagName": {
"prefix": "ett",
"body": ["e.target.tagName"]
},
"e.target.dataset": {
"prefix": "etd",
"body": ["e.target.dataset.$1"]
},
"params": {
"prefix": "pa",
"body": ["params"]
},
"catch": {
"prefix": "ca",
"body": [".catch(err=>{$1})"]
},
// -------------------------------------------属性---------------------------
// -------------------------------------------web API-----------------------
// 定时器
"setInterval": {
"prefix": "seti",
"body": ["setInterval(function () {", "\t$1", "}, 1000)"],
"description": "开启定时器-间歇函数"
},
"setTimeout": {
"prefix": "sett",
"body": ["setTimeout(function () {", "\t$1", "}, 1000)"],
"description": "开启定时器-延迟函数"
},
// 注册事件
"click": {
"prefix": "cli",
"body": ["$1.addEventListener('click',function () {", "\t", "})"],
"description": "注册点击事件"
},
"mouseenter": {
"prefix": "enter",
"body": ["$1.addEventListener('mouseenter',function () {", "\t", "})"],
"description": "注册鼠标移入事件"
},
"mouseleave": {
"prefix": "leave",
"body": ["$1.addEventListener('mouseleave',function () {", "\t", "})"],
"description": "注册鼠标移出事件"
},
"mouseover": {
"prefix": "over",
"body": ["$1.addEventListener('mouseover',function () {", "\t", "})"],
"description": "注册鼠标移入事件-冒泡"
},
"mouseout": {
"prefix": "out",
"body": ["$1.addEventListener('mouseout',function () {", "\t", "})"],
"description": "注册鼠标移出事件-冒泡"
},
"mousemove": {
"prefix": "move",
"body": ["$1.addEventListener('mousemove',function () {", "\t", "})"],
"description": "鼠标在页面移动时触发事件"
},
"blur": {
"prefix": "bl",
"body": ["$1.addEventListener('blur',function () {", "\t", "})"],
"description": "失去焦点事件"
},
"focus": {
"prefix": "foc",
"body": ["$1.addEventListener('focus',function () {", "\t", "})"],
"description": "获取焦点事件"
},
"keydown": {
"prefix": "keydown",
"body": ["$1.addEventListener('keydown',function () {", "\t", "})"],
"description": "键盘按下触发事件"
},
"keyup": {
"prefix": "keyup",
"body": ["$1.addEventListener('keyup',function () {", "\t", "})"],
"description": "键盘抬起触发事件"
},
"input": {
"prefix": "inp",
"body": ["$1.addEventListener('input',function () {", "\t", "})"],
"description": "用户输入事件"
},
"submit": {
"prefix": "submit",
"body": ["$1.addEventListener('submit',function () {", "\t", "})"],
"description": "用户提交事件"
},
"load": {
"prefix": "load",
"body": ["window.addEventListener('load',function(){", "\t$1", "})"],
"description": "页面加载事件"
},
"DOMContentLoaded": {
"prefix": "loaded",
"body": [
"document.addEventListener('DOMContentLoaded',function(){",
"\t$1",
"})"
],
"description": "页面加载事件"
},
"scroll": {
"prefix": "scr",
"body": ["window.addEventListener('scroll',function () {", "\t$1", "})"],
"description": "滚动事件"
},
"resize": {
"prefix": "resize",
"body": ["window.addEventListener('resize',function () {", "\t$1", "})"],
"description": "页面缩放事件"
},
"touchstart": {
"prefix": "star",
"body": ["$1.addEventListener('touchstart',function () {", "\t", "})"],
"description": "移动端触摸开始事件"
},
"touchend": {
"prefix": "end",
"body": ["$1.addEventListener('touchend',function () {", "\t", "})"],
"description": "移动端触摸离开事件"
},
"touchmove": {
"prefix": "mov",
"body": ["$1.addEventListener('touchmove',function () {", "\t", "})"],
"description": "移动端移动事件"
},
"change": {
"prefix": "change",
"body": ["$1.addEventListener('change',function () {", "\t", "})"],
"description": "内容发生变化触发事件"
},
"timeupdate": {
"prefix": "update",
"body": ["$1.addEventListener('timeupdate',function () {", "\t", "})"],
"description": "视频播放触发事件"
},
"loadeddata": {
"prefix": "ddata",
"body": ["$1.addEventListener('loadeddata',function () {", "\t", "})"],
"description": "视频加载完后触发事件"
},
"scrollTop": {
"prefix": "dp",
"body": ["document.documentElement.scrollTop"],
"description": "页面滚出的高度"
},
"preventDefault": {
"prefix": "pre",
"body": ["e.preventDefault()"],
"description": "阻止默认行为"
},
"stopPropagation": {
"prefix": "stop",
"body": ["e.stopPropagation()"],
"description": "阻止冒泡"
},
// 获取元素
"querySelector": {
"prefix": "ds",
"body": ["document.querySelector('$0')"],
"description": "获取单个元素"
},
"querySelectorAll": {
"prefix": "dsa",
"body": ["document.querySelectorAll('$0')"],
"description": "获取多个元素"
},
// 节点操作
"parentNode": {
"prefix": "par",
"body": ["$1.parentNode"],
"description": "获取父元素"
},
"children": {
"prefix": "chi",
"body": ["$1.children"],
"description": "获取子元素"
},
"createElement": {
"prefix": "dcr",
"body": [" document.createElement('$1')"],
"description": "创建元素"
},
"appendChild": {
"prefix": "app",
"body": ["$1.appendChild()"],
"description": "插入节点,在父元素最后"
},
"insertBefore": {
"prefix": "ins",
"body": [" $1.insertBefore(,)"],
"description": "插入到某个子节点前面"
},
"cloneNode": {
"prefix": "clon",
"body": ["$1.cloneNode()"],
"description": "克隆节点"
},
"removeChild": {
"prefix": "rem",
"body": ["$1.removeChild()"],
"description": "删除节点"
},
// 本地存储
"l.setItem": {
"prefix": "lset",
"body": ["localStorage.setItem('$1',JSON.stringify())"],
"description": "长久存储"
},
"l.getItem": {
"prefix": "lget",
"body": ["localStorage.getItem('$1')"],
"description": "获取数据"
},
"l.removeItem": {
"prefix": "lrem",
"body": ["localStorage.removeItem('$1')"],
"description": "删除数据"
},
"s.setItem": {
"prefix": "sset",
"body": ["sessionStorage.setItem('$1','')"],
"description": "短暂存储"
},
"s.getItem": {
"prefix": "sget",
"body": ["sessionStorage.getItem('$1')"],
"description": "获取数据"
},
"s.removeItem": {
"prefix": "srem",
"body": ["sessionStorage.removeItem('$1')"],
"description": "删除数据"
},
// json对象
"stringify": {
"prefix": "jsons",
"body": ["JSON.stringify($1)"],
"description": "对象转为字符串对象"
},
"parse": {
"prefix": "jsonp",
"body": ["JSON.parse($1)"],
"description": "字符串对象转为对象"
},
// -------------------------------web API---------------------
// ------------------------------JS进阶------------------------------
"map": {
"prefix": "ma",
"body": ["$1.map((ele,index)=>{})"],
"description": "map映射方法"
},
"filter": {
"prefix": "fil",
"body": ["$1.filter((ele,index)=>{})"],
"description": "filter过滤方法"
},
"forEach": {
"prefix": "fore",
"body": ["$1.forEach((ele,index)=>{})"],
"description": "forEach遍历方法"
},
"reduce": {
"prefix": "re",
"body": ["$1.reduce((prev,current)=>{},0)"],
"description": "reduce累加方法"
},
"find": {
"prefix": "find",
"body": ["$1.find((ele,index)=>{})"],
"description": "find找满足条件元素"
},
"findIndex": {
"prefix": "findIndex",
"body": ["$1.findIndex((ele,index)=>{})"],
"description": "findIndex找满足条件的下标"
},
"every": {
"prefix": "every",
"body": ["$1.every((ele,index)=>{})"],
"description": "所有元素满足条件返回true"
},
"some": {
"prefix": "some",
"body": ["$1.some((ele,index)=>{})"],
"description": "只要有一个元素满足条件返回true"
},
// ------------------------------JS进阶------------------------------
// ------------------------------ajax------------------------------
"axios-get": {
"prefix": "get",
"body": [" axios({url: '',params: {}}).then(res => {})"],
"description": "get请求"
},
"axios-post": {
"prefix": "post",
"body": [" axios({url: '',method:'post',data: {}}).then(res => {})"],
"description": "post请求"
},
"axios-del": {
"prefix": "del",
"body": [" axios({url: '',method:'delete'}).then(res => {})"],
"description": "delete请求"
},
"axios-put": {
"prefix": "put",
"body": [" axios({url: '',method:'put'}).then(res => {})"],
"description": "put请求"
},
"serialize": {
"prefix": "ser",
"body": [" serialize($1,{hash:true,empty:true})"],
"description": "serialize获取表单内容"
},
"setRequestHeader": {
"prefix": "xhrset",
"body": [" xhr.setRequestHeader('Content-Type', 'application/json')"],
"description": "setRequestHeader"
},
"loadend": {
"prefix": "loadend",
"body": [
" xhr.addEventListener('loadend', function () {console.log(xhr.response)})"
],
"description": "loadend"
}
// ------------------------------ajax------------------------------
}