代码之家  ›  专栏  ›  技术社区  ›  iulian

“tagName.className+Tab”等同于WebStorm中的属性

  •  2
  • iulian  · 技术社区  · 8 年前

    现实:

    在WebStorm(v.10.0.4)中,与许多其他IDE/文本编辑器一样 table.table.table-striped + tab 为您节省了一些时间和字符 <table class="table table-striped"></table> .

    有类似的功能 id 属性: div#one -> <div id="one"></div> .

    使用Bootstrap,这很好。但对于“角度材质”(Angular Material),它在元素上有许多自定义属性,这是不够的。

    问题:

    有没有办法在WebStorm中定义一种类似于 <tag>.<className> 用属性而不是CSS类动态生成标签?

    迄今为止我所做的:

    我看过Live Templates,但它们只能定义静态模板,这意味着我必须对每个可能的标签属性对进行硬编码。我也找不到 <标签>&书信电报;类名称> 功能驻留在中,以便在其上构建一些东西。

    1 回复  |  直到 8 年前
        1
  •  4
  •   lena    8 年前

    此功能基于 Emmet 缩写。看见 https://www.jetbrains.com/webstorm/help/emmet-support.html , https://www.jetbrains.com/webstorm/help/expanding-emmet-templates-with-user-defined-templates.html 有关WebStorm中Emmet支持的更多信息。

    特别是,要生成具有特定属性的HTML元素,需要使用 tag_name[attr=value] 语法,

    例如: link[rel=prefetch title="Hello world"] 生成 <link rel="prefetch" href="" title="Hello world">