简体   繁体   English

在 Visual Studio 代码中的字符串中自动完成 html 标记?

[英]autocomplete html tags in strings in Visual Studio code?

Is this possible in Visual Studio?这在 Visual Studio 中可行吗? I'm following a Wes Bos tutorial and while he's typing html in backticks (therefore in a string) in javascript, the html end tags autocomplete.我正在关注 Wes Bos 教程,当他在 javascript 中的反引号(因此在字符串中)键入 html 时,html 结束标签自动完成。

Are you looking for this extension ?您在寻找此扩展程序吗?

It allows syntax highlighting and auto completion inside tagged template strings.它允许在标记的模板字符串中突出显示语法和自动完成。

I found bierner.lit-html works perfectly.我发现bierner.lit-html效果很好。

I tried Tobermory.es6-string-html too but this only gives syntax highlighting, not autocompletion.我也试过Tobermory.es6-string-html但这只会突出语法,而不是自动完成。

Note that both require you to prefix your html strings with a special comment, or html :请注意,两者都要求您在 html 字符串前加上特殊注释或html

class DashboardView extends View {
  __html__ = html`
    <div class="mt-8 px-2 text-center">
      Look, syntax highlighting!
    </div>
  `
}

Don't worry about the html prefix, it doesn't interfere with your code, and is recognised in other places which handle markdown like github, and as you can see, stackoverflow:不用担心html前缀,它不会干扰您的代码,并且在其他处理 markdown 的地方(如 github)也可以识别,正如您所见,stackoverflow:

class DashboardView extends View {
  __html__ = `
    <div class="mt-8 px-2 text-center">
      No syntax highlighting :-(
    </div>
  `
}

And the cherry on the cake is that other plugins which operate on HTML such as bradlc.vscode-tailwindcss which adds tailwindcss class intellisense also work:蛋糕上的樱桃是其他在 HTML 上运行的插件,例如bradlc.vscode-tailwindcss它添加了 tailwindcss class intellisense 也可以工作:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio Code 自动完成已损坏 - Visual Studio Code AutoComplete is broken 如何在Visual Studio代码上设置WebGL自动完成? - How to setup WebGL autocomplete on Visual Studio Code? visual studio代码和Parse.com自动完成? - visual studio code and Parse.com autocomplete? Visual Studio 2012无法识别html标记 - Visual Studio 2012 does not recognize html tags 有时代码未显示在Visual Studio代码的自动完成列表中,解决方案? - Sometimes Code Not Showing In Autocomplete List For Visual Studio Code, Solution? React 中 HTML 标签的自动完成在 VS Code 中不起作用 - Autocomplete of HTML tags in React aren't working in VS Code Visual Studio 自动完成功能不适用于 html 页面上的 javascript/css - Visual Studio autocomplete not working for javascript / css on html page 智能感知和自动完成在 Visual Studio 代码中不起作用 - Intellisense and autocomplete doesn't work in Visual studio code JavaScript 的 Visual Studio Code 自动完成/IntelliSense 无法正常工作 - Visual Studio Code autocomplete/IntelliSense not working properly for JavaScript Visual Studio Code 不会自动完成 javascript 方法,例如 padStart() - Visual Studio Code does not autocomplete javascript methods like padStart()
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM