Any Snippets
一些常用的代码片段
{
"打印": {
"prefix": "cc",
"body": [
"console.log('【LOG】$1',$2);"
],
"description": "输出到控制台"
},
"打印红色背景": {
"prefix": "cr",
"body": [
"console.log('\\x1B[41m%s\\x1B[49m',JSON.stringify($2, null, 2),'$1');"
],
"description": "输出到控制台且红色强提醒"
},
"打印对象": {
"prefix": "cco",
"body": [
"console.log('\\x1B[43m%s\\x1B[49m', '========================================','$1');",
"console.log('\\x1B[33m%s\\x1b[0m:',JSON.stringify($2, null, 2));",
"console.log('\\x1B[43m%s\\x1B[49m', '========================================');"
],
"description": "打印对象在node"
},
"打印对象在safari": {
"prefix": "co",
"body": [
"console.log('========================================', '$1');",
"console.info(JSON.stringify($1, null, 2));",
"console.log('========================================', '$1');",
],
"description": "打印对象在safari"
},
"打印jsapi": {
"prefix": "jsa",
"body": [
"console.log('========================================', '[jsapi]$1');",
"console.info(JSON.stringify(result$2, null, 2));",
],
"description": "打印jsapi"
},
"打印": {
"prefix": "cc",
"body": [
"console.log('【LOG】$1',$2);"
],
"description": "输出到控制台"
},
"打印红色背景": {
"prefix": "cr",
"body": [
"console.log('\\x1B[41m%s\\x1B[49m',JSON.stringify($2, null, 2),'$1');"
],
"description": "输出到控制台且红色强提醒"
},
"打印对象": {
"prefix": "cco",
"body": [
"console.log('\\x1B[43m%s\\x1B[49m', '========================================','$1');",
"console.log('\\x1B[33m%s\\x1b[0m:',JSON.stringify($2, null, 2));",
"console.log('\\x1B[43m%s\\x1B[49m', '========================================');"
],
"description": "打印对象在node"
},
"打印对象在safari": {
"prefix": "co",
"body": [
"console.log('========================================', '$1');",
"console.info(JSON.stringify($1, null, 2));",
"console.log('========================================', '$1');",
],
"description": "打印对象在safari"
},
"打印jsapi": {
"prefix": "jsa",
"body": [
"console.log('========================================', '[jsapi]$1');",
"console.info(JSON.stringify(result$2, null, 2));",
],
"description": "打印jsapi"
},
"kv": {
"prefix": "kv",
"body": [
"",
"\"$1\":\"$2\","
]
},
"kn": {
"prefix": "kn",
"body": [
"",
"\"$1\":$2,"
]
},
"wh": {
"scope": "less,css",
"prefix": "wh",
"body": [
"width: $1;",
"height: $1;"
],
"description": "宽高同频"
},
"箭头异步函数": {
"scope": "javascript,typescript,typescriptreact",
"prefix": "ca=>",
"body": [
"const $1 = async () => {",
" $2",
"}",
],
"description": "箭头异步函数"
},
"箭头函数": {
"scope": "javascript,typescript,typescriptreact",
"prefix": "c=>",
"body": [
"const $1 = () => {",
" $2",
"}",
],
"description": "箭头函数"
},
"JSX": {
"scope": "javascript,typescript,typescriptreact",
"prefix": ".{}",
"body": [
".{styles.$1}",
],
"description": "JSX"
},
"useState": {
"scope": "javascript,typescript,typescriptreact",
"prefix": "uss",
"body": [
"const [$1, set_$1] = useState<$2>($3);",
],
"description": "设置useState"
},
"css": {
"scope": "javascript,typescript,typescriptreact",
"prefix": "css",
"body": [
"import styles from './style.module.less';",
],
"description": "引入css"
},
"request": {
"scope": "javascript,typescript,typescriptreact",
"prefix": "rq",
"body": [
"try {",
" const res = await $1 ({",
" $2",
" });",
" set$3(res); ",
"} catch (e) {",
" handleActionError(e);",
"}",
],
"description": "发起请求"
},
"expoLog": {
"scope": "javascript,typescript,typescriptreact",
"prefix": "zjlog",
"body": [
"logClick({",
" fans: `a9999.b9999.c9999.d9999`,",
" trackerParams: {",
" ____DEBUG____: JSON.stringify({",
" $1 :$2,",
" }),",
" },",
"});",
],
"description": "通过埋点在安卓真机输出log"
},
}