首页 前端知识 vscode如何创建自定义快捷键模板(typescript React示例)

vscode如何创建自定义快捷键模板(typescript React示例)

2024-05-30 10:05:01 前端知识 前端哥 811 71 我要收藏

1.vs面板左下角设置-配置用户代码片段

2. 弹出搜索框中输入typescript会出来2个选项,选择第二个react

 3.在代码片段中添加自己的快捷键设置片段(用$TM_FILENAME_BASE$1可以获取当前文件的名称)

{
	// Place your snippets for typescriptreact 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"
	// }
	"tsxr": {
		"prefix": "tsxr",
		"body": [
			"import React from 'react';",
			"",
			"const $TM_FILENAME_BASE$1: React.FC = () => {",
			"  return (",
			"    <div></div>",
			"  );", 
			"}",
			"",
			"export default $TM_FILENAME_BASE$1;"
		],   
		"description": "TypeScript React FC component"
	} 
}

转载请注明出处或者链接地址:https://www.qianduange.cn//article/10039.html
标签
评论
发布的文章

JQuery中的load()、$

2024-05-10 08:05:15

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!