美文网首页
VS Code自定义代码片段快捷键

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

作者: NextStack | 来源:发表于2017-10-17 17:39 被阅读0次

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

    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

    相关文章

      网友评论

          本文标题:VS Code自定义代码片段快捷键

          本文链接:https://www.haomeiwen.com/subject/quoduxtx.html