如何在 VS 代码中的 JavaScript 字符串中语法高亮显示 HTML?

How to syntax-highlight HTML inside JavaScript strings in VS code?

JavaScript 字符串中的语法高亮 HTML 是否有任何 Vs 代码扩展?

具体来说我在写web组件

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 常量变量中的字符串

如果你使用lit-html,vs code中有一个语法高亮插件叫lit-plugin。 语法是,

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