使用vscode,新建.vue文件,tab自动生成vue代码模板

第一步: 新建模板并保存vue

文件 --> 首选项 --> 用户代码片断 --> 输入vue,选择vue.json -->复制 第三步中的模板内容中内容保存web

第二步: 添加配置,让vscode容许自定义的代码片断提示出来json

文件 --> 首选项 --> 设置 ---> 添加这2项ecmascript

// Specifies the location of snippets in the suggestion widget
"editor.snippetSuggestions": "top",
// Controls whether format on paste is on or off
"editor.formatOnPaste": true

第三步: 复制如下代码,保存重启vscodewebstorm

{
    "Print to console": {
        "prefix": "vue",
        "body": [
            "<template>",
            "  <div class=\"page\">\n",
            "  </div>",
            "</template>\n",
            "<script type=\"text/ecmascript-6\">",
            "export default {",
            "  data() {",
            "    return {\n",
            "    }",
            "  },",
            "  components: {\n",
            "  }",
            "}",
            "</script>\n",
            "<style scoped lang=\"stylus\">",
            "</style>",
            "$2"
        ],
        "description": "Log output to console"
    }
}

第四步:测试是否添加成功测试

测试方法: 新建vue后缀文件,输入vue,按下tab键,OKcode

缺点是:没法像sublime同样新建一个vue文件就能够自动带上对应的模板。component

吐槽一下:webstorm中,中文输入法兼容有问题,据传是Microsoft .NET Framework 4.5.2以上版本的兼容问题,更换屡次版本后没法修复。无奈只能换到vscodeorm

相关文章
相关标签/搜索