VS Code自定义代码片段快捷键
2017-10-17 本文已影响0人
NextStack
有时候想快速输入一段代码片段
这时候只需要进入这里就可以编辑快捷代码片段了:

然后输入你的语言,比如js后缀,就用javascript:
{
"react-native": {
"prefix": "react-native",
"body": [
"import React, { Component } from \"react\";",
"import {",
"\tView,",
"\tText,",
"} from \"react-native\";",
"",
"export default class $1 extends Component {",
"\tstatic propTypes = {}",
"\tstatic defaultProps = {}",
"\tconstructor (props) {",
"\t\tsuper(props);",
"\t}",
"",
"\trender () {",
"\t\treturn (",
"\t\t\t<View>",
"\t\t\t\t<Text>$2</Text>",
"\t\t\t</View>",
"\t\t)",
"\t}",
"}"
],
"description": "初始化ReactNative组件"
}
}
这样,在编辑器中输入react-native
即可快捷输入:
