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"
}
}