美文网首页
VS Code中vue文件的格式化

VS Code中vue文件的格式化

作者: 白雪公主960 | 来源:发表于2018-07-05 20:13 被阅读80次

开发过程中发现,格式化vue文件时总是不生效,本人通过以下方法已解决了原来的问题。
在文件==》首选项==》设置==》用户设置当中,放入以下代码即可。


{   "window.title": "${dirty}${activeEditorLong}${separator}${rootName}${separator}${appName}",
    "window.zoomLevel": 0,
    "workbench.colorTheme": "Default Light+",
    "extensions.ignoreRecommendations": true,
    "emmet.syntaxProfiles": {
        "vue-html": "html",
        "vue": "html"
    },
    "vetur.validation.template": false,
    "eslint.options": {
        "plugins": ["html"]
    },
    "eslint.validate": [
        "javascript",
        "javascriptreact",
        "html",
        "vue"
    ],
    "prettier.singleQuote": true,
    "prettier.semi": false,
    "vetur.format.defaultFormatter.html": "js-beautify-html",
    "vetur.format.defaultFormatterOptions": {
         "wrap_attributes": "force-expand-multiline"
    //    "js-beautify-html": {
    //     "wrap_attributes": "force-expand-multiline",
    //     "end_with_newline": false
    //   }
     }
}

其中wrap_attributes属性设置了格式化代码时的换行规则,
比如当某标签的属性过多时,不想放在同一行中,就可以设置其属性值为force-expand-multiline。
其他可选值为: [auto|force|force-aligned|force-expand-multiline] ["auto"]

相关文章

网友评论

      本文标题:VS Code中vue文件的格式化

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