如何在VS代码中的JavaScript字符串中语法高亮显示HTML? [英] How to syntax-highlight HTML inside JavaScript strings in VS code?

查看:62
本文介绍了如何在VS代码中的JavaScript字符串中语法高亮显示HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JavaScript字符串中是否有Vs Code扩展以语法突出显示HTML?

Is there any Vs Code extension to syntax-highlight HTML inside JavaScript strings?

特别是我正在编写Web组件

Specifically I am writing web components

const html = content => `
  <div>
    <table>
      ${content}
    </table>
  </div>
`;

class BaseTable extends HTMLElement {
  constructor() {
    super();
  }

  set content(value) {
    const template = document.createElement('template');
    template.innerHTML = style + html(value);

    this.attachShadow({ mode: 'open' });
    this.shadowRoot.appendChild(template.content.cloneNode(true));
  }
}

我希望html常量变量内的字符串突出显示

I want string inside html constant variable to be highlighted

推荐答案

如果您使用lit-html ,则vs代码中有一个名为lit-plugin的插件,用于突出显示语法.语法是

If you use lit-html, There's a plugin in vs code called lit-plugin for syntax highlighting. Syntax is,

const markup = content => html`
  <div>
    <table>
      ${content}
    </table>
  </div>
`;

这篇关于如何在VS代码中的JavaScript字符串中语法高亮显示HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆