Visual Studio Code HTML 和 CSS linter 验证器定制

问题描述 投票:0回答:1

是否有一种简单的方法来自定义 Visual Studio Code HTML / CSS linter 验证规则的行为?

我希望有可能将数据占位符放入样式、属性、文本节点的代码中,例如:

<style type="text/css">

   .testa {
      color: white;
      background-color: navy;
      transition: color 1s, background-color 1s;
   }

</style>

<template>

   <div class="testa" onclick="{{testClick}}" style="background-color: {{backgroundColor}}; color: {{color}}" >
      {{firstName}} {{lastName}} {{firstName} {{lastName}}
   </div>

   <div style="{{style}}">
      {{firstName}} {{lastName}}
   </div>

</template>

它不需要是 {{...}} 占位符。它可以是其他任何东西,例如 ${},但我希望 Visual Studio Code 不将此报告为错误,同时仍有可能启用智能感知和验证。

html css validation visual-studio-code lint
1个回答
0
投票

为 Visual Studio Code 安装一个 Twig 插件。 (这是我找到的第一个。)

然后告诉Visual Studio Code

.html
设置下将
file.associations
文件与Twig相关联。
{{firstName}}
是有效的 Twig 代码,所以 Visual Studio Code 会认为它没问题。

© www.soinside.com 2019 - 2024. All rights reserved.