在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML/ vscode 格式化插件

vscode 格式化插件

使用vscode開(kāi)發(fā)vue項(xiàng)目,目前.vue文件無(wú)法一鍵同時(shí)格式化html,js,css。

  1. 使用過(guò)vetur,暫未經(jīng)過(guò)配置,只能格式化html,js,css其中一個(gè),另外兩個(gè)格式亂的不能用,如果用這個(gè)的話(huà),怎么配置?;
  2. 曾經(jīng)用過(guò)vue-beauty,以前沒(méi)問(wèn)題的,但現(xiàn)在有嚴(yán)重bug,不能用,還有其他可用的插件么;
  3. vscode有沒(méi)有一鍵導(dǎo)出配置的功能或者插件,能導(dǎo)入大佬的設(shè)置和插件就好了。
回答
編輯回答
九年囚

貼一下我在寫(xiě) vue 時(shí)候的 vscode 的配置過(guò)程,ESlint 是建議的

1. 需插件安裝

  • Vetur : 語(yǔ)法高亮等功能
  • ESlint : 代碼風(fēng)格檢測(cè)
  • Prettier formatter for Visual Studio Code: 為了配合 ESlint

2. 插件設(shè)置

  • vue 的模板格式化:
    "vetur.format.defaultFormatter.html":"js-beautify-html"
  • vue 模板的 eslint 校驗(yàn)
    "eslint.validate": [
        "javascript",
        "javascriptreact",
        "html",
        "vue",
        {
            "language": "html",
            "autoFix": true
        }
    ]
  • Prettier 設(shè)置去除不必要空格:"prettier.semi": false
  • Prettier 設(shè)置格式化后"'"prettier.singleQuote": true
  • 在 vscode 中排除 node_modules 等文件夾:
"files.exclude": {
    "**/.git": true,
    "**/.svn": true,
    "**/.hg": true,
    "**/CVS": true,
    "**/.DS_Store": true,
    "**/node_modules": true,
    "**/package-lock.json": true,
},
  • 以新行結(jié)束

"html.format.endWithNewline": false

完整的 vue 相關(guān)用戶(hù)設(shè)置如下

"files.exclude": {
    "**/.git": true,
    "**/.svn": true,
    "**/.hg": true,
    "**/CVS": true,
    "**/.DS_Store": true,
    "**/node_modules": true,
    "**/package-lock.json": true
},
"vetur.format.defaultFormatter.html": "js-beautify-html",
"editor.formatOnSave": true,
"prettier.semi": false,
"prettier.singleQuote": true,
"html.format.endWithNewline": true,
"eslint.validate": [
    "javascript",
    "javascriptreact",
    "html",
    "vue",
    {
        "language": "html",
        "autoFix": true
    }
]
2017年6月3日 08:28
編輯回答
痞性
"prettier.singleQuote": true,
"prettier.semi": false,
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"vetur.format.defaultFormatter.js": "vscode-typescript",
"vetur.format.defaultFormatter.html": "js-beautify-html",
"vetur.format.defaultFormatterOptions": {
    "wrap_attributes": "force-aligned"
},

這是自己搜索到的,復(fù)制這個(gè)配置,重啟后,我的需求基本滿(mǎn)足了。

2017年3月14日 15:10