vscode vue 插件安装


vetur、Prettier - Code formatter、ESLint一起安装:

设置:在打开的窗口中的【文件】---【首选项】---【用户设置】中加入下面内容:

{    
    
// prettier:每行在这个字符数内整合代码,如果你的屏幕较宽分辨率较高可以适当加大
 "prettier.printWidth": 120, 
 // prettier:是否在每行末尾加上分号
  "prettier.semi": false, 
 // prettier:如果为true,将使用单行否则使用双引号
  "prettier.singleQuote": true, 
 // vetur:对html的内容使用js-beautify-html
  "vetur.format.defaultFormatter.html": "js-beautify-html",
  "workbench.colorTheme": "Solarized Dark",
  "workbench.iconTheme": "vscode-icons",
  "explorer.confirmDragAndDrop": false
}

Auto Close Tag --------自动补全html标签

Auto Rename Tag --------同步更改html尾标签

HTML CSS Support css--------语法提示

HTML Snippets html--------标签提示

JavaScript (ES6) snippets ES6--------语法快捷键支持

language-stylus stylus --------语法提示

Stylus stylus CSS 语法提示--------主要支持vue文件下stylus

Path Autocomplete --------文件自动路径提示

VS Color Picker color: #fff --------自动提示

Vue 2 Snippets vue --------快捷键提示

eslint--------代码格式化(不装)

VueHelper --------可能是目前vscode最好的vue代码提示插件

vetur --------必备

 

ESLint ESlint--------语法提示

修改settings.json 文件

"eslint.nodePath": "E:/WebStorm", // 应用路径
"eslint.validate": [
"javascript",
"javascriptreact",
"vue" // 添加vue文件支持
] 

File Peek 文件路径跳转

修改settings.json 文件

"file_peek.activeLanguages": [
"typescript",
"javascript",
"python",
"vue" // 添加vue支持
],
"file_peek.searchFileExtensions": [
".js",
".ts",
".html",
".css",
".scss",
".vue" // 添加vue支持
]

 最后的settings.json

  
{
    "python.pythonPath": "D:\\Program Files\\Python36\\python.exe",
    "editor.fontWeight": "100",
    "workbench.colorTheme": "Monokai", //指定工作台中使用的颜色主题
    "workbench.preferredDarkColorTheme": "Solarized Dark",
    "editor.formatOnType": true,
    // Specifies the location of snippets in the suggestion widget
    "editor.snippetSuggestions": "top",
    // Controls whether format on paste is on or off
    "editor.formatOnPaste": true,
    "emmet.triggerExpansionOnTab": true,
    "emmet.includeLanguages": {
        "vue-html": "html",
        "vue": "html"
    },
    "editor.renderIndentGuides": false,
    "eslint.nodePath": "D:/Microsoft VS Code", // 应用路径
    // prettier:每行在这个字符数内整合代码,如果你的屏幕较宽分辨率较高可以适当加大
    "prettier.printWidth": 120,
    // prettier:是否在每行末尾加上分号
    "prettier.semi": false,
    // prettier:如果为true,将使用单行否则使用双引号
    "prettier.singleQuote": true,
    "workbench.iconTheme": "vscode-icons",
    "explorer.confirmDragAndDrop": false,
    "vetur.completion.scaffoldSnippetSources": {},
    "vetur.validation.template": false,
    "eslint.codeAction.disableRuleComment": {},
    "workbench.editor.enablePreview": false, //打开文件不覆盖
    "search.followSymlinks": false, //关闭rg.exe进程
    "editor.minimap.enabled": false, //关闭快速预览
    "liveServer.settings.donotShowInfoMsg": true, //关闭liveserver提示
    "files.autoSave": "afterDelay", //打开自动保存
    "editor.fontSize": 16, //设置文字大小
    "editor.lineHeight": 24, //设置文字行高
    "editor.lineNumbers": "on", //开启行数提示
    "editor.quickSuggestions": { //开启自动显示建议
        "other": true,
        "comments": true,
        "strings": true
    },
    "window.zoomLevel": 0, // 调整窗口的缩放级别
    "editor.tabSize": 2, //制表符符号eslint
    "editor.formatOnSave": true, //每次保存自动格式化
    //"eslint.autoFixOnSave": true, // 每次保存的时候将代码按eslint格式进行修复
    "prettier.eslintIntegration": true, //让prettier使用eslint的代码格式进行校验
    "javascript.format.insertSpaceBeforeFunctionParenthesis": true, //让函数(名)和后面的括号之间加个空格
    "vetur.format.defaultFormatter.html": "js-beautify-html", //格式化.vue中html
    "vetur.format.defaultFormatter.js": "vscode-typescript", //让vue中的js按编辑器自带的ts格式进行格式化
    "vetur.format.defaultFormatterOptions": {
        "js-beautify-html": {
            "wrap_attributes": "force-aligned" //属性强制折行对齐
        }
    },
    "eslint.validate": [ //开启对.vue文件中错误的检查
        "javascript",
        "javascriptreact",
        {
            "language": "html",
            "autoFix": true
        },
        {
            "language": "vue",
            "autoFix": true
        }
    ],
    "eslint.migration.2_x": "off",
}

 第二方法只装插件:

{
  // vscode默认启用了根据文件类型自动设置tabsize的选项
  "editor.detectIndentation": false,
  // 重新设定tabsize
  "editor.tabSize": 2,
  // #每次保存的时候自动格式化 
  "editor.formatOnSave": true,
  // #每次保存的时候将代码按eslint格式进行修复
  "eslint.autoFixOnSave": true,
  // 添加 vue 支持
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    {
      "language": "vue",
      "autoFix": true
    },
    {
      "language": "javascript",
      "autoFix": true
    }
  ],
  //  #让prettier使用eslint的代码格式进行校验 
  "prettier.eslintIntegration": true,
  //  #去掉代码结尾的分号 
  "prettier.semi": false,
  //  #使用带引号替代双引号 
  "prettier.singleQuote": true,
  //  #让函数(名)和后面的括号之间加个空格
  "javascript.format.insertSpaceBeforeFunctionParenthesis": true,
  // #这个按用户自身习惯选择 
  "vetur.format.defaultFormatter.html": "js-beautify-html",
  // #让vue中的js按编辑器自带的ts格式进行格式化 
  "vetur.format.defaultFormatter.js": "vscode-typescript",
  "vetur.format.defaultFormatterOptions": {
    "js-beautify-html": {
      "wrap_attributes": "auto"
      // #vue组件中html代码格式化样式
    }
  },
  // 格式化stylus, 需安装Manta's Stylus Supremacy插件
  "stylusSupremacy.insertColons": false, // 是否插入冒号
  "stylusSupremacy.insertSemicolons": false, // 是否插入分好
  "stylusSupremacy.insertBraces": false, // 是否插入大括号
  "stylusSupremacy.insertNewLineAroundImports": false, // import之后是否换行
  "stylusSupremacy.insertNewLineAroundBlocks": false,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "files.associations": {
  
  } // 两个选择器中是否换行
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM