本文是从简书复制的, markdown语法可能有些出入, 想看"正版"和更多内容请关注 简书: 小贤笔记

位置

  • ctrl+shift+p
  • 搜索: snippets
  • 输入类型: 比如 htmljavascript

参数说明

  • prefix:使用代码段的快捷入口
  • body:需要设置的代码放在这里,字符串间换行的话使用\r\n换行符隔开.如果值里包含特殊字符需要进行转义,多行代码以","分隔(在引号后面写逗号)
  • $0:定义最终光标位置
  • $1:定义第一次光标位置,按tab键可进行快速切换, 还可以有 $2, $3, $4, $5 ...
  • description:代码段描述,在使用智能感知时的描述

常用字符说明

  • \\ 反斜杠
  • \a 警告
  • \b 退格符
  • \f 换页符
  • \n 换行符
  • \r 回车符
  • \t Tab 符
  • \v 垂直 Tab 符
  • \u 使用数字指定的Unicode 字符, 如 \u2000
  • \x 使用十六进制数指定的Unicode 字符, 如 \xc8
  • \0 空值

HTML

    //自定义
"phone": {
"prefix": "ph",
"body": [
"<!DOCTYPE html>",
"<html lang='en'>",
"<head>",
" <meta charset='UTF-8'>",
" <meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>",
" <meta name='viewport' content='width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0'/>",
" <title>Titile</title>",
"</head>",
"<body>",
"<script type='text/javascript'>",
" $('html').css({fontSize:$(window).width()/375*100 + 'px'});",
" $('body').css({minHeight:$(window).height()});",
"</script>",
"</body>",
"</html>"
],
"description": "script"
},
"script": {
"prefix": "sc",
"body": [
"<script type='text/javascript' src='$1'></script>"
],
"description": "script"
}

JavaScript

	// 自定义
"function": {
"prefix": "fn",
"body": [
"function$1($2) {\r\n\t$3\r\n}"
],
"description": "function(){}"
},
"console.log": {
"prefix": "co",
"body": [
"console.log ($1);"
],
"description": "console.log()"
},
"alert": {
"prefix": "al",
"body": [
"alert ($1);"
],
"description": "alert()"
},
"class": {
"prefix": "cl",
"body": [
"$('.$1')"
],
"description": "class"
},
"id": {
"prefix": "id",
"body": [
"$('#$1')"
],
"description": "id"
},
"on": {
"prefix": "on",
"body": [
"on ('click',function () {\r\n\t$1\r\n})"
],
"description": "on"
},
"for": {
"prefix": "fo",
"body": [
"for (let i=0; i<$1; i++) {\r\n\t$2\r\n}"
],
"description": "for"
},
"if": {
"prefix": "ifif",
"body": [
"if ($1) {\r\n\t$2\r\n}"
],
"description": "if"
},
"ifElse": {
"prefix": "ifel",
"body": [
"if ($1) {\r\n\t$2\r\n} else {\r\n\t$3\r\n}"
],
"description": "ifElse"
},
"ajax": {
"prefix": "aj",
"body": [
// "$.ajax({\r\n\turl:$1,\r\n\tdata:{\r\n\t\t$2\r\n\t},\r\n\ttype:'post',\r\n\tdataType:'JSON',\r\n\tsuccess:function (res) {\r\n\t\t$3\r\n\t}\r\n})"
"$.ajax({",
" url: $1,",
" data:{",
" $2",
" },",
" type: 'post',",
" dataType: 'JSON',",
" success:function (res) {",
" $3",
" }",
"})"
],
"description": "ajax"
},
"axios": {
"prefix": "ax",
"body": [
"axios.$1(__PROJECTPATH__ + `$2`, {",
" $3",
"})",
".then(function (response) {",
" console.log(response);",
"})",
".catch(function (error) {",
" console.log(error);",
"});",
],
"description": "axios"
}

Vue

注: 组件/实例的书写顺序参照 Vue 风格指南

	// 自定义(移动端)
"vue": {
"prefix": "vu",
"body": [
"<!-- $1 -->",
"<template>",
" <div>",
" $2",
" </div>",
"</template>",
"",
"<script>",
" export default {",
" name: '',",
" components: {",
" ",
" },",
" props: {",
" ",
" },",
" data() {",
" return {",
" ",
" }",
" },",
" computed: {",
" ",
" },",
" watch: {",
" ",
" },",
" created() {",
" ",
" },",
" methods: {",
" ",
" },",
" }",
"</script>",
"",
"<style scoped lang='less'>",
" ",
"</style>"
],
"description": "Vue templet"
}

最新文章

  1. Binary XML file line #2: Error inflating
  2. 初学Scala
  3. 将Web站点由IIS6迁移至IIS7
  4. AX 插入一条记录提示表记录已经存在,但是该记录实际上是不存在的。
  5. Java Hotspot G1 GC的一些关键技术
  6. 快速创建maven 工程:simple java工程,webapp
  7. 求相同号码一天内的上网流量——mapreduce
  8. POJ1321棋盘问题
  9. python 错误、调试和测试
  10. Windows服务承载WCF
  11. WPF发布程序后未授予信任的解决办法
  12. SqlServer IF Exists([database]|[table]|[prop]) / Column([Operation])
  13. unittest框架概要
  14. Java之路——名词解释(一)
  15. 【BZOJ4009】接水果(整体二分,扫描线)
  16. 深入理解Spring Redis的使用 (九)、通过Redis 实现 分布式锁 的 BUG,以及和数据库加锁的性能测试
  17. Springboot 6.Springboot 返回cookies信息的验证和post接口开发及常见错误解决
  18. Spring Cloud 和 Dubbo 比较
  19. java 写一个类,实现对象数的计算
  20. HoloLens开发手记 - 使用HoloLens模拟器 Using HoloLens emulator

热门文章

  1. 关于window.open在不同浏览器的不同点
  2. Jmeter将JDBC Request查询结果作为下一个接口参数方法(转载)
  3. Codeforces Round #545 (Div. 2) 题解
  4. P4027 [NOI2007]货币兑换
  5. linux 系统管理(2) 文件或目录数量统计
  6. JS获取后台返回的JSON数据
  7. Linux 系统下安装 mysql5.7.25(glibc版)
  8. 初探flow.js
  9. 使用vmware虚拟机安装linux
  10. Linux du与df命令的差异