VS Code自定义代码片段快捷键

2017-10-17  本文已影响0人  NextStack

有时候想快速输入一段代码片段
这时候只需要进入这里就可以编辑快捷代码片段了:

Screen Shot 2017-10-17 at 17.37.48.png

然后输入你的语言,比如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即可快捷输入:

Screen Shot 2017-10-17 at 17.39.16.png
上一篇 下一篇

猜你喜欢

热点阅读