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

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

2024-05-30 10:05:01 前端知识 前端哥 796 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
标签
评论
发布的文章

使用 mapstructure 解析 json

2024-06-05 13:06:03

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