如何注释掉 .Vue 模板中的 HTML 标签

Ray*_*Ray 5 html javascript vue.js visual-studio-code

最近,我开始学习 Vue 并使用 Vue-Cli。有一个问题,我无法使用热键(VSCode)注释掉 .html 文件中的 HTML 标记。当我使用“Ctrl+/”时,我想注释掉这样的行。

// <div> comment out this line</div>
Run Code Online (Sandbox Code Playgroud)

不是这样的。

<!--<div> comment out this line</div>-->
Run Code Online (Sandbox Code Playgroud)

是否有可能我更改了 VSCode 中的某些设置导致这种情况?有谁知道如何解决这个问题?

Neo*_*ard 7

就像 tony19 提到的,安装Vetur VSCode 扩展添加了 Vue 语言支持,它可以在 Vue 文件中正确设置注释切换。


Kam*_*que -1

对于单行注释,请使用Ctrl+ /。这会做这样的事情

// <div> comment out this line</div>
Run Code Online (Sandbox Code Playgroud)

对于块注释,请使用Ctrl+ Shift+ /。这将像这样注释行

<!-- <div> comment out this line</div>

     <div> comment out this line</div>

     <div> comment out this line</div> -->
Run Code Online (Sandbox Code Playgroud)

或者

/* <div> comment out this line</div>

   <div> comment out this line</div>

   <div> comment out this line</div> */
Run Code Online (Sandbox Code Playgroud)

为了改变快捷键

  • Windows:文件 > 首选项 > 键盘快捷键。

  • MacOS:代码 > 首选项 > 键盘快捷键。

然后搜索像这样的评论截图