VS Code 寫vue推薦方式

推薦

VS Code(1.22.1) + vetur + eslint + stylelint + prettierjavascript

安裝

npm install -g vue-language-server
npm install -g stylelint
npm install -g eslint
npm install -g prettier prettier-eslintcss

配置

VS Code 配置html

{
    "emmet.syntaxProfiles": {
        "vue-html": "html",
        "vue": "html"
    },

    "eslint.autoFixOnSave": true,
    "eslint.options": {
        "extensions": [
            ".js",
            ".vue"
        ]
    },
    "eslint.validate": [
        "javascript",
        "javascriptreact",
        "html",
        "vue",
        "vue-html",
        {
            "language": "vue",
            "autoFix": true
        },
        {
            "language": "html",
            "autoFix": true
        }
    ],

    "stylelint.enable": true,
    "css.validate": false,
    "scss.validate": false,

    "stylelint.additionalDocumentSelectors": [
        "vue"
    ],

    "vetur.format.styleInitialIndent": true,
    "vetur.format.scriptInitialIndent": true,
    "vetur.format.defaultFormatter.html": "js-beautify-html"
}

工程跟目錄下配置vue

  • .eslintrc.js
  • .stylelintrc
  • .prettierrc

截圖

圖片描述

自帶格式化以後:
圖片描述java

連接

VS Code
vetur
eslint
stylelint
prettierreact

相關文章
相關標籤/搜索