You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VS Code缩进竖线异常求助:Vue CLI项目仅单个.vue文件显示正常

解决VS Code中Vue文件缩进竖线显示不一致的问题
  • 检查文件语言模式
    确认所有.vue文件右下角的语言模式都是Vue,如果是其他模式(比如Plain Text),VS Code不会渲染对应文件的缩进竖线。点击右下角语言模式,选择"Vue"即可统一设置。

  • 统一缩进线全局/工作区设置
    打开VS Code设置(快捷键Ctrl+, / Cmd+,),搜索并开启以下选项:

    • editor.renderIndentGuides: 设置为true
    • editor.guides.indentation: 设置为true
    • editor.guides.highlightActiveIndentation: 可选开启,用于高亮当前光标所在的缩进层级
      也可以直接在settings.json中添加配置:
    {
      "editor.renderIndentGuides": true,
      "editor.guides.indentation": true,
      "editor.guides.highlightActiveIndentation": true
    }
    
  • 重置单个文件的局部设置
    若部分文件存在个性化设置覆盖全局配置的情况,按Ctrl+Shift+P / Cmd+Shift+P输入Preferences: Reset File Settings,重置该文件的设置,恢复到全局/工作区配置。

  • 检查项目的.editorconfig配置
    查看项目根目录的.editorconfig文件,确保所有Vue文件的缩进规则统一,比如:

    [*.vue]
    indent_style = space
    indent_size = 2
    

    不一致的缩进规则可能导致VS Code无法正确渲染缩进竖线。

  • 确认Vetur/Volar的配置兼容
    确保Vetur或Volar的格式化设置与VS Code的缩进设置匹配,比如Volar的volar.format.options.tabSize要和VS Code的editor.tabSize保持一致,避免因格式化差异导致缩进线不显示。

内容的提问来源于stack exchange,提问作者nicolabz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 02:10:27