自用vscode代码片段

180 阅读1分钟

{ // Place your 全局 snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is // used to trigger the snippet and the body will be expanded and inserted. Possible variables are: // 1,1, 2 for tab stops, 0forthefinalcursorposition,and0 for the final cursor position, and {1:label}, {2:another} for placeholders. // Placeholders with the same ids are connected. // Example: "Print to console": { "scope": "javascript,typescript", "prefix": "log", "body": \[ "console.log('1');", "2" \], "description": "Log output to console" }, "视口标签": { "prefix": "shikou", "body": \[ "<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0, minimum-scale=1.0\\">" \], "description": "快速生成理想视口标签" }, "单行文本溢出": { "prefix": "danhang", "body": \[ "overflow: hidden;", "text-overflow: ellipsis;", "white-space: nowrap;" \], "description": "单行文本溢出" }, "多行文本溢出": { "prefix": "duohang", "body": \[ "overflow: hidden;", "text-overflow: ellipsis;", "display: -webkit-box;", "-webkit-line-clamp: 2;", "-webkit-box-orient: vertical;", "word-break: break-all;" \], "description": "多行文本溢出" }, "媒体查询": { "prefix": "meiti", "body": \[ "@media screen and (min-width: 1px) {", "}" ], "description": "快速生成媒体查询代码" }, "模板引擎过滤器": { "prefix": "guolvqi", "body": [ "template.defaults.imports.函数名 = function () {", "}" ], "description": "快速生成模板引擎过滤器" }, "xhr设置 Content-Type 属性": { "prefix": "xhr Content-Type", "body": [ "xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')" ], "description": "快速生成xhr Content-Type 属性" }, "xhr设置 监听事件": { "prefix": "xhr 监听事件", "body": [ "xhr.onreadystatechange = function () {", "if (xhr.readyState === 4 && xhr.status === 200) {", "console.log(xhr.responseText)", "}", "}" ], "description": "快速生成xhr 监听事件" }, "xhr设置 文件上传进度": { "prefix": "xhr 上传进度", "body": [ "xhr.upload.onprogress = function (e) {", "if (e.lengthComputable) {", // 计算出上传的进度 " var procentComplete = Math.ceil((e.loaded / e.total) * 100)", "}", "}" ], "description": "快速生成xhr 文件上传进度" }, }