惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MongoDB | Blog
MongoDB | Blog
V
V2EX
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
有赞技术团队
有赞技术团队
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
罗磊的独立博客
月光博客
月光博客
爱范儿
爱范儿
D
Docker
U
Unit 42
P
Proofpoint News Feed
I
InfoQ
腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
L
LangChain Blog
V
Visual Studio Blog
IT之家
IT之家
Vercel News
Vercel News
G
Google Developers Blog
M
MIT News - Artificial intelligence
美团技术团队
The GitHub Blog
The GitHub Blog
阮一峰的网络日志
阮一峰的网络日志
MyScale Blog
MyScale Blog

博客园 - 醒着/☆☆

移动硬盘删除不了东西 updata(dt:number)的常用用法 关键字 堆栈实现四则混合运算 在线资源 JS相比TS的缺点(或TS的优点) Vscode的JS debug环境 Cocos Creator-TypeScript与JS快速过渡 GooglePlay FB相关 上传速度慢 CocosCreator与Laya2.0区别 LayaBox 常用技巧 CSV的规范与使用 Laya2.0的转变 Laya for H5 之Bug追踪 TypeScript: this bind 和 回调的正确用法 常用资源 意外发现一个具有名称 的外部可见定义
常见的代码片段
醒着/☆☆ · 2019-10-30 · via 博客园 - 醒着/☆☆

TypeScipt的用户代码片段

{
	"create class":{
		"prefix": "crtc",
		"body": [
			"/** Created by Naiking.",
			" *  $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
			" *  ",
			" */",
			"//Learn TS:https://docs.cocos.com/creator/manual/zh/scripting/typescript.html",
			"//Learn Attribute:https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html",
			"//Life-cycle:https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html",
			"const {ccclass, property} = cc._decorator;",
			"@ccclass",
			"export default class $TM_FILENAME_BASE extends cc.Component {",
			"\t//@property(cc.Label)",
			"\t//label: cc.Label = null;",
			"\t//onLoad(){}",
			"\tstart(){",
			"\t\t",
			"\t}",
			"\tupdate(dt){}",
			"}"]
	},
}

提供一套较常见的“用户代码片段”
“文件”--“首选项”--“用户代码片段”--选择一个你需要设置的开发语言
本例是以javascript为例。(typesciprt的也同样的定义关键字)

其实这个文件,已经提供的一个最基础的示例了。
我的自定义添加了:创建文件块,加入作者,创建时间,设置光标,缩进符号

{
	// Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and 
	// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
	// same ids are connected.
	// Example:
	// "Print to console": {
	// 	"prefix": "log",
	// 	"body": [
	// 		"console.log('$1');",
	// 		"$2"
	// 	],
	// 	"description": "Log output to console"
	// }
	"import namespace":{
		"prefix": "import",
		"body": "let $1=require('$1');",
		"description": "import"
	},
	"create class":{
		"prefix": "crtc",
		"body": [
			"/** Created by Naiking.",
			" *  $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
			" *  ",
			" */",
			"var $TM_FILENAME_BASE = cc.Class({",
			"// extends: cc.Component,",
			"\tname: '$TM_FILENAME_BASE',",
			"\tproperties: {",
			"\t\t$1",
			"\t},",
			"\tctor: function () {",
			"\t\t//this.xxx=arguments[0];",
			"\t}",
			"});",
			"module.exports =$TM_FILENAME_BASE;"]
	},
	"signal instance":{
		"prefix": "signal",
		"body": [
		"_instance:null,",
        "getInstance:function(){",
            "\tif(!$TM_FILENAME_BASE._instance)",
            "\t{",
                "\t\t$TM_FILENAME_BASE._instance=new $TM_FILENAME_BASE();",
            "\t}",
            "\treturn $TM_FILENAME_BASE._instance;",
        "}"
		]
	},
	"add new event type":{
		"prefix": "evttype",
		"body": "$1:'$1'"
	}
}

更详细的请参阅:
https://blog.csdn.net/maokelong95/article/details/54379046